Developer
URL Encoding
URL encoding, also called percent-encoding, replaces characters that have a special meaning or are unsafe in a URL with a percent sign followed by their hexadecimal byte value.
Updated 12 Aug 2026
Why URLs need escaping
A URL is not free text. Characters such as ?, &, =, /, # and space each carry structural meaning, so a value containing them would change how the URL is parsed. Percent-encoding replaces each unsafe byte with %XX, letting arbitrary text ride safely inside a path or query parameter.
Which characters are safe
- Unreserved and always safe: A–Z, a–z, 0–9, hyphen, underscore, period and tilde
- Reserved and escaped when used as data: ? & = # / : @ + and space
- Space becomes %20 in paths, and may be + in traditional form submissions
- Non-ASCII text is encoded as its UTF-8 bytes, so é becomes %C3%A9
Encode the part, not the whole
In JavaScript, encodeURI is meant for a complete URL and deliberately leaves structural characters alone. encodeURIComponent is for a single value and escapes them. Using the wrong one is the usual cause of parameters that silently truncate at an ampersand.
Double encoding
Encoding an already-encoded value turns %20 into %2520. Decode first, or encode exactly once at the boundary.
Encoding the whole URL
Escaping :// and ? breaks the URL structure entirely.
Forgetting the plus sign
In form-encoded bodies + means space, so a literal plus must be sent as %2B.
URL Encoder
Convert values safely and spot double-encoding at a glance.
Characteristics
- Each unsafe byte becomes % followed by two hex digits
- Based on UTF-8 bytes, so one character may produce several escapes
- Reversible and lossless
- Rules differ slightly between path segments, query strings and form bodies
Common uses
- Placing search terms and filters in query strings
- Building safe redirect and callback URLs in OAuth flows
- Encoding filenames and identifiers inside paths
- Submitting HTML forms as application/x-www-form-urlencoded
Advantages
- Lets any text travel inside a URL without ambiguity
- Universally implemented in browsers, servers and libraries
- Fully reversible
- Preserves non-ASCII characters through UTF-8
Limitations
- Encoded URLs are hard for people to read
- Expands length, and URLs have practical limits
- Easy to apply twice, producing broken values
- Context-dependent rules trip up developers regularly
Examples
Raw: search?q=tea & coffee/café
Encoded: search?q=tea%20%26%20coffee%2Fcaf%C3%A9
Double-encoded (wrong): q=tea%2520%2526%2520coffeeFrequently asked questions
What is URL encoding used for?
Putting text that contains reserved or non-ASCII characters into a URL without breaking its structure.
Why is a space shown as %20?
Spaces are not permitted in URLs, so they are replaced by the percent-encoded value of the space byte.
What is the difference between encodeURI and encodeURIComponent?
encodeURI preserves structural characters for a whole URL; encodeURIComponent escapes them and is correct for a single value.
How do I fix a double-encoded URL?
Decode until the value stops changing, then encode exactly once when you rebuild the URL.
Is URL encoding the same as Base64?
No. URL encoding escapes unsafe characters in place; Base64 re-encodes bytes into a different alphabet.
Related terms
Character Encoding
Character encoding is the mapping between the characters people read and the bytes computers store, defining how text is turned into binary and back again.
UTF-8
UTF-8 is a variable-width Unicode encoding that represents every character in one to four bytes and is fully backwards compatible with ASCII.
Base64
Base64 is an encoding scheme that represents binary data using 64 printable ASCII characters so it can travel safely through text-only channels.
API
An API (Application Programming Interface) is a defined contract that lets one piece of software request data or actions from another without knowing how it works internally.
UUID
A UUID is a 128-bit identifier, written as 36 hexadecimal characters, designed to be unique without any central coordination between the systems that generate it.
Minification
Minification removes every byte a machine does not need — whitespace, line breaks, comments and long names — from code or data without changing what it does.
Related tools
Related guides
URL Encoding Explained (Percent-Encoding)
Why URLs need encoding, which characters are reserved, the difference between encodeURI and encodeURIComponent, plus and space confusion, and how to avoid double encoding.
Base64 Explained: What It Is and When to Use It
How Base64 turns binary into text, why output is about 33% larger, where padding comes from, URL-safe variants, and why Base64 is encoding rather than encryption.
How to Format JSON (Beautify, Indent and Minify)
Learn how JSON formatting works, see a before-and-after example, fix the errors that block beautifying, and format JSON online in your browser without uploading a file.
Compress PDF Without Losing Quality
Honest guide to shrinking a PDF without wrecking it: Lossless (small safe savings), Compress images (re-encode photos, keep text selectable), and Rasterize (biggest savings, flattens pages). Pick the mode that matches your file.