URL Encoder / Decoder
Encode a string for use inside a URL (or decode percent-escapes back to text). Shows component vs full-URI variants and base64url for token use.
Result
How to use this calculator
- Pick a direction.
- Encode mode: copy whichever variant you need (component / URI / form / base64url).
- Decode mode: paste any percent-escaped or base64url string and read the original text.
About this calculator
URL percent-encoding is the convention every web framework uses to embed non-URL-safe characters inside a URL. Reserved characters like &, =, ?, /, and space get rewritten as %XX (the hex of the UTF-8 byte). For a path segment or query-string VALUE you almost always want encodeURIComponent — encodeURI is much more permissive and is meant for re-escaping an already-built URL. This tool runs both, plus the form-encoding variant (space→+) and base64url for JWT-style token use.
How it works — the formula
encodeURIComponent: char ∉ [A-Za-z0-9-_.~!*'()] → %XX of UTF-8 byte
encodeURI: same, but also excludes reserved URI syntax: / ? # [ ] @ etc.
base64url: base64 with +→- /→_ and trailing = strippedPercent-encoding is byte-level: encode UTF-8 bytes one at a time. A multi-byte character produces multiple %XX sequences. Decoding reassembles the UTF-8 byte stream and re-decodes to a string.
Worked examples
- Inputs:
- mode=encode, text=hello world
- Output:
- hello%20world
- Inputs:
- mode=encode, text=&=?
- Output:
- %26%3D%3F (component) / &=? (URI)
- Inputs:
- mode=decode, text=%E4%B8%AD
- Output:
- 中 (U+4E2D)
Limitations
- encodeURI vs encodeURIComponent semantics follow WHATWG / RFC 3986 specs.
- base64url decode is attempted only when input matches the alphabet.
- No automatic URL parsing — for splitting a full URL into scheme/host/path/query use a URL parser.
Encodings round-trip exactly: decode(encode(x)) === x for any UTF-8 string.
Frequently asked
When should I use encodeURIComponent vs encodeURI?+
What is the difference between %20 and + in URLs?+
What is base64url?+
Why does the decoder fail on some inputs?+
Does this handle Unicode correctly?+
Related calculators
More tools you might like
Hand-picked tools that pair well with this one — same audience, same intent.
Look up the ASCII/Unicode codepoint for any character — or go the other way and turn a list of codepoints back into text. Shows decimal, hex (U+XXXX), octal, binary, HTML entity, JS escape, and URL-encoded forms for every code point.
Convert numbers between hexadecimal, binary, octal, and decimal. Shows the bit pattern grouped by nibble + the two’s-complement representation for negative values.
Build the canonical text payload encoded in a QR code — plain text, URL, WiFi-network credentials, or vCard contact. Includes a ready-to-render image URL for visual scanning.
(Target salary + overhead + profit margin) / billable hours = full freelance hourly rate.
Count words, characters, paragraphs, and sentences in any pasted text, plus reading time at 250 / 200 / 150 WPM.
Find text and cover it with black rectangles — visual redaction. For full text-stream removal, use a paid pro tool.