Codificador URL - Codificação URL Segura

Voltar para Ferramentas

About URL Encoding

URL encoding (percent-encoding) converts characters into a format that can be transmitted over the Internet. This tool safely encodes special characters, spaces, and non-ASCII characters for use in URLs, form data, and HTTP requests.

RFC 3986 Compliant Special Characters Support Batch Processing Real-time Encoding
When to Use
  • Form data transmission
  • URL parameter encoding
  • Query string construction
Pro Tip: Always encode user input before including it in URLs to prevent security vulnerabilities and ensure proper data transmission.
Codifique texto e caracteres especiais para transmissão URL segura. Perfeito para criar parâmetros de consulta, dados de formulário e solicitações de API. Previne URLs quebradas e garante transmissão adequada de dados.

What is URL Encoding?

URL encoding is a mechanism for converting characters into a valid ASCII format for transmission over the internet. It replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits representing the character's ASCII code.

How URL Encoding Works

The encoding process converts each unsafe character to its hexadecimal ASCII representation, prefixed with a percent sign (%). This ensures all characters can be safely transmitted in URLs.

Encoding Rules

Reserved characters (like ?, &, =) and unsafe characters (like spaces, quotes) are encoded. Safe characters (A-Z, a-z, 0-9, -, ., _, ~) remain unchanged.

URL Encoding Examples

Special Characters

Original: Hello World!

Encoded: Hello%20World%21

Email Address

Original: user@example.com

Encoded: user%40example.com

Query Parameters

Original: name=John Doe&age=25

Encoded: name%3DJohn%20Doe%26age%3D25

Special Symbols

Original: $100 & 50% off

Encoded: %24100%20%26%2050%25%20off

Technical Details

Reserved Characters
: / ? # [ ] @ ! $ & ' ( ) * + , ; =
Unsafe Characters
Space " < > % { } | \ ^ ` [ ]
Encoding Format

Each encoded character follows the pattern: % + two hexadecimal digits representing the ASCII value.

Example: Space (ASCII 32) = %20, @ (ASCII 64) = %40

Common Use Cases

Form Data Submission

Encode form data before sending HTTP POST requests to ensure special characters are properly transmitted.

URL Parameter Construction

Create safe URL parameters by encoding values that may contain spaces or special characters.

API Request Building

Prepare data for RESTful API calls where parameters need to be URL-safe for GET requests.

Web Development

Ensure user-generated content can be safely included in URLs without breaking the request structure.

Best Practices & Tips

Always Encode User Input

Never trust user input - always encode data before including it in URLs to prevent injection attacks.

Encode Only When Necessary

Don't encode already-encoded strings to avoid double-encoding issues that can corrupt data.

Use Proper Character Set

Ensure your application uses consistent character encoding (UTF-8) throughout the encoding process.

Validate Before Encoding

Validate and sanitize input data before encoding to catch potential security issues early.

Test with Edge Cases

Test your encoding with special characters, unicode, and edge cases to ensure robust handling.

Document Encoding Requirements

Clearly document which parts of your API or application require URL-encoded input.

Common Issues & Troubleshooting

Double Encoding Problem

URLs become corrupted when encoding already-encoded strings (e.g., %20 becomes %2520).

Check if data is already encoded before applying URL encoding. Implement detection logic.

Character Set Mismatch

Non-ASCII characters display incorrectly after encoding due to character set issues.

Ensure consistent UTF-8 encoding throughout your application and specify charset in headers.

Plus Sign Confusion

Plus signs (+) in URLs may be interpreted as spaces in form data encoding.

Use %2B for literal plus signs in URLs, or + for spaces in application/x-www-form-urlencoded.

Reserved Character Problems

Reserved characters break URL structure when not properly encoded.

Always encode reserved characters (?, &, =, etc.) when they appear in parameter values.