URL percent-encoding represents characters with % followed by two hexadecimal digits derived from their UTF-8 bytes. It lets text such as spaces, accented letters, and reserved punctuation travel through URL components without being mistaken for URL syntax.
This tool provides separate rules for a component, a full URL, and form-style data. It can also decode percent-encoded text, report malformed sequences, and swap the result into the opposite mode for a quick round trip.
How to Use the URL Encoder and Decoder
Choose the context before encoding, because reserved characters are handled differently.
- Select Encode or Decode under Mode.
- Choose Component (encodeURIComponent), Full URL (encodeURI), or Form data (spaces as +) from Variant.
- Enter content in Text to encode or Encoded text to decode, according to the selected mode.
- Review Encoded output or Decoded text and the character count in the status message.
- Select Swap to move the output into the input and switch between Encode and Decode, or select Copy to copy the output.
Components, Full URLs, and Reserved Characters
Component (encodeURIComponent) is designed for one value that will occupy part of a URL, such as a query parameter value or path segment. It percent-encodes URL syntax characters including &, =, /, ?, and #, preventing data from being interpreted as new delimiters.
const value = "café & tea";
const url = "/search?q=" + encodeURIComponent(value);
Full URL (encodeURI) keeps structural delimiters such as :, /, ?, #, &, and = readable while encoding characters that cannot appear directly. Use it only when the input already contains the complete URL structure. It is not appropriate for an untrusted query value because an ampersand or hash in that value remains active syntax.
Encoding does not parse, normalize, or validate a URL. The tool does not check the scheme, host, port, path rules, or whether the destination exists. Use the URL parser when you need to inspect a URL's structural parts after constructing it.
Form Data, Spaces, and Plus Signs
The Form data (spaces as +) encoder first applies component encoding, then replaces encoded spaces (%20) with +. This matches the familiar space convention used by application/x-www-form-urlencoded data. A literal plus sign in the source becomes %2B, keeping it distinct from a space.
In Decode mode, selecting Form data (spaces as +) changes every + to a space before percent-decoding. The other two variants leave plus signs unchanged. This distinction explains why C++ can accidentally become C when generic URL text is decoded as form data.
The form option handles one string; it does not parse a query into names and values, add separators, or serialize an object. Encode keys and values separately before joining them with = and &, or use a platform API such as URLSearchParams when building complete form/query data.
Form serialization has details beyond spaces, including ordering and how applications interpret repeated keys. Follow the receiving endpoint's documented contract. Do not assume that a percent-encoded string is a complete or valid request body.
Decoding Errors and Double-Encoding
Decoding uses decodeURIComponent for the complete input in every variant. For the form variant only, plus signs are converted to spaces first. The Full URL selection affects encoding, but it does not switch decoding to decodeURI; consequently, encoded reserved characters such as %2F and %3F are decoded too.
A percent sign must be followed by two hexadecimal digits, and the resulting byte sequence must represent valid UTF-8 for decoding to succeed. On failure, the output is cleared and the tool reports: Malformed percent-encoding: a % must be followed by two hex digits that form valid UTF-8.
Double-encoding happens when already encoded text is encoded again. %20 becomes %2520 because the percent sign becomes %25. One decode then returns %20, not a space. Keep track of which layer owns encoding instead of repeatedly encoding until a value appears to work.
Encoding malformed JavaScript text, such as an unpaired UTF-16 surrogate, can also fail in the browser's built-in encoder. The tool displays the resulting error and clears the output. Ordinary Unicode text, including accented characters and emoji, is encoded through its UTF-8 representation.
Security and Local URL Handling
Encoding is not input validation and does not make a URL trustworthy. A decoded value may contain script-like text, path traversal sequences, control characters, or delimiters that regain meaning when inserted into another context. Validate the decoded value for its intended use and encode it again at the final output boundary.
Context matters: URL encoding does not replace HTML escaping, JavaScript string escaping, SQL parameters, or shell argument handling. If a URL is placed in HTML, construct and validate the URL first, then apply the protections required by that HTML context. Avoid manually combining transformations whose order is unclear.
The encoding and decoding operations run locally in your browser; input is not uploaded for processing. Still, redact passwords, access tokens, signed links, and private query values before sharing screenshots or copied output. Percent-encoding is reversible representation, not encryption.
Be cautious with decoded redirect targets and user-controlled schemes. Parsing with a URL API and applying an explicit allowlist of protocols and destinations is more reliable than checking whether a string merely starts with familiar text. For other reversible text encodings, see the Base64 encoder and decoder.
Frequently Asked Questions
Should I use encodeURI or encodeURIComponent?
Use the component variant for an individual query value, key, or path segment because it encodes structural delimiters. Use the full-URL variant when the input already contains URL structure that should remain recognizable. Neither choice validates that the resulting URL is allowed or reachable.
Why are spaces sometimes %20 and sometimes +?
Percent-encoding represents a space as %20. Form-style serialization conventionally uses + for a space, which is why the form variant changes %20 after component encoding. Outside form/query parsing, a plus sign may be literal and should not automatically become a space.
Why did %2520 appear in my output?
The input probably contained %20 and was encoded again. Encoding converts the existing percent sign to %25, producing %2520. Decode one layer at a time and identify which system is responsible for each layer before changing production logic.
Can this tool validate a complete URL?
No. It transforms characters but does not parse the scheme, hostname, port, path, query, or fragment and does not test whether a resource exists. Use a URL parser or the browser's URL API for structure, then apply application-specific validation.
Why does decoding fail on a percent sign?
Every percent sign in encoded input must begin a two-digit hexadecimal byte, and consecutive bytes must decode as valid UTF-8. A stray %, a non-hex pair such as %G0, or an invalid UTF-8 sequence causes the tool to clear the output and show its malformed percent-encoding message. A literal percent sign should be encoded as %25.
References: RFC 3986: Uniform Resource Identifier Syntax · WHATWG URL Standard.