URL Encoder / Decoder
Stop breaking links with spaces and ampersands.
URL Encoder / Decoder
Percent-encode text for a query string or path, or turn an encoded URL back into readable text.
Encoding uses encodeURIComponent, which is the correct choice for a query parameter value. Decoding also converts + to a space, as form submissions do.
33 characters
Embed this calculator
Put this calculator on your own site with the snippet below. The frame contains the tool only, reports its own height, and carries a visible link back to the full page. Embedding is free; keep the attribution link as it is, and do not wrap the frame in a way that hides it.
Preparing the embed code for this page...
What This Calculator Does
The URL Encoder and Decoder converts text to percent-encoded form and back. It uses encodeURIComponent, the correct choice for a query parameter value or path segment, and decodes + as a space the way form submissions do.
How It Works
Reserved and non-ASCII characters are replaced by a percent sign followed by their UTF-8 bytes in hexadecimal. A space becomes %20. Decoding reverses the process, but a lone or truncated % sequence is invalid and is reported rather than silently dropped.
Example
The text "search=hello world&page=1" encodes to "search%3Dhello%20world%26page%3D1", with the ampersand and equals sign escaped so they cannot be read as query separators. Decoding it returns the original string.
Formula
Unreserved characters stay; everything else becomes %XX per UTF-8 byte%XX → byte, then UTF-8 decode; + → space in form dataReading the Results
Output
The encoded or decoded string. Encoding a full URL rather than a single component will escape the separators and break it, so encode values one at a time.
Sources and References
RFC 3986 — Uniform Resource Identifier (URI): Generic Syntax
Percent-encoding and reserved characters
Defines which characters may appear literally and how percent-encoding works.
WHATWG URL Standard
application/x-www-form-urlencoded serialisation
Explains why + represents a space in form-encoded data but not in a path.
References identify the method or data behind this calculator. Where a standard or tariff changes, the current edition applies, and the assumptions stated above take precedence over a remembered figure.
Frequently Asked Questions
Should I use encodeURI or encodeURIComponent?
Use encodeURIComponent for a parameter value or path segment, because it escapes reserved characters such as & and =. Use encodeURI only for a complete URL where you want to preserve its structure.
Why does a space sometimes become + and sometimes %20?
In application/x-www-form-urlencoded data, + means space. In a URI path, + is a literal plus and space must be %20. This tool encodes spaces as %20 and accepts + as a space when decoding.
What causes the invalid percent-encoding error?
A % not followed by two hex digits, or a sequence of bytes that is not valid UTF-8. Copying a URL that was truncated or double-encoded is the usual cause.
Is my text sent anywhere?
No. Encoding and decoding happen entirely in your browser. Nothing is uploaded or stored, which is why the tool is safe for internal URLs and test parameters.
