The JS URL Encoder on FreeToolZones percent-encodes text so it can travel safely inside a web address. URLs have strict rules about which characters may appear unescaped: spaces, ampersands, question marks, non-ASCII characters, and several others either break an address or change its meaning if they appear raw. Percent-encoding replaces each such character with a percent sign followed by two hexadecimal digits representing its UTF-8 byte, producing text that survives transport through browsers, servers, and links intact. This tool offers the three encoding modes JavaScript itself provides, so you can encode a single query value, a whole URL, or form data, each correctly for its context.
Choosing the wrong mode is the most common URL encoding mistake, and it is easy to make: encoding a whole URL as if it were a single value destroys its structure, while encoding a single value as if it were a whole URL leaves dangerous characters unescaped. The tool labels each mode by its purpose, not just by its function name, so the right choice is clear. It runs entirely in your browser, using the built-in JavaScript encoding functions, which means the output matches exactly what your own code would produce with the same functions.
What Is the JS URL Encoder?
The JS URL Encoder is a free online tool that applies JavaScript percent-encoding to text you enter. It offers three modes in a menu. The first mode, encodeURIComponent, is for a query value: a single piece of data that will sit inside a URL, such as a search term or a name. It encodes everything except letters, digits, and a small set of unreserved punctuation, including characters that have structural meaning in a URL, such as ampersand, equals, question mark, and slash. That thoroughness is what makes a value safe to embed: no character in the value can be mistaken for URL structure.
The second mode, encodeURI, is for a full URL: a complete address that should stay readable and functional. It encodes characters that are not allowed in a URL, such as spaces and non-ASCII characters, but leaves the structural characters alone, so the scheme, the slashes, the question mark, the ampersands, and the equals signs that organize the address remain intact. Encoding a whole address this way fixes the characters that would break it without destroying the address itself.
The third mode, form encoding, starts from the query-value encoding and then replaces each encoded space with a plus sign. That is the convention for HTML form submissions using the application/x-www-form-urlencoded format, where spaces in field values are written as plus signs rather than as percent-twenty. If you are preparing data that will be submitted or parsed as form data, this mode produces the expected form. For ordinary query values in a link, the first mode is the safer default, because a plus sign in a query value is not universally read as a space.
The tool shows no statistics, because the output speaks for itself: the encoded text appears below, with a Copy button. The Load sample button fills the input with a full example address containing a search query with a space, which is an ideal demonstration: encode it in each mode and compare the results to see how the same input is treated differently depending on the context you choose. The hint on the page summarizes the guidance: use the query-value mode when encoding one value inside a URL, and the full-URL mode when the whole address should stay readable.
How to Use the JS URL Encoder
Encoding takes three steps, and the mode choice is the step that matters most.
- Enter your text or URL. Click in the box labeled Text or URL and type or paste what you want to encode. It can be a single value, such as a search term, or a complete address. The box accepts any characters, including spaces, symbols, and non-ASCII text.
- Choose an encoding mode. Use the Encoding mode menu to pick encodeURIComponent for a query value, encodeURI for a full URL, or Form encoding when spaces should become plus signs. If you are unsure, ask what the output will be part of: one value inside an address means the first mode, a whole address means the second, and form-submitted data means the third.
- Press Encode and copy the result. Click the Encode button. If the box is empty, the tool asks you to enter some text first. Otherwise the encoded text appears below, with a Copy button. Press Copy, then paste the result where it belongs: into a link, a query string, or a form value.
Before using the result in production, test it. Paste an encoded address into a browser and confirm it loads the intended page. For an encoded value, decode it with the JS URL Decoder and confirm it returns the original text. That round trip catches the two most common mistakes: encoding the wrong part of an address, and encoding an already-encoded value a second time, which turns each percent sign into its own encoding and produces a value that decodes to encoded text rather than to the original.
Key Features of the JS URL Encoder
The three modes are the feature set, and each one maps to a real JavaScript function with well-defined behavior.
Query-value encoding with encodeURIComponent
This mode encodes every character that could be mistaken for URL structure, including ampersand, equals, question mark, slash, hash, and plus, along with spaces and non-ASCII characters. The result is safe to place as a single value in a query string, a path segment, or any other position where the value must not leak into the surrounding structure.
Full-URL encoding with encodeURI
This mode encodes only characters that are invalid in a URL, leaving structural characters untouched. A complete address comes out still recognizable as an address, with its scheme, host, path, and query intact, and only the problematic characters, such as spaces and non-ASCII letters, percent-encoded. It is the right mode for cleaning up an address copied from a document or a chat message.
Form encoding with plus signs for spaces
This mode applies query-value encoding and then converts encoded spaces to plus signs, matching the form submission convention. It is the right mode when the output will be parsed as form-encoded data, where a plus sign is read as a space. The checkbox on the companion decoder, which treats plus as a space, is the matching option on the decoding side.
Built-in functions and copy-ready output
Because the tool uses the browser built-in encoding functions, its output is identical to what JavaScript code using the same functions produces. There is no custom encoding logic to diverge from the standard. The Copy button takes the exact output to your clipboard.
Practical Use Cases
URL encoding appears wherever text meets addresses. The examples below cover the everyday cases.
Building a link with a search term
Suppose a user searches for a phrase containing spaces and an ampersand, and you need to build a link to the results page. Encoding the phrase as a query value ensures the spaces and the ampersand become percent sequences, so the server receives one value instead of a broken query. Encoding the whole link the same way would destroy it, which is why the mode choice matters.
Cleaning up a pasted address
Addresses copied from documents, emails, and chat messages often contain spaces, where a line break crept in, or non-ASCII characters in a path. Encoding the whole address in full-URL mode fixes those characters while keeping the address structure, producing a link that works when pasted into a browser or shared with someone else.
Preparing form data
When you construct a form-encoded body by hand, for testing an endpoint or for a script, values must follow the form convention, including plus signs for spaces. The form mode produces that form directly, so the receiving parser reads the values as intended. Testing with the companion decoder, with its plus-as-space option ticked, confirms the round trip.
Handling non-ASCII text in addresses
Names, titles, and phrases in languages beyond English contain characters that cannot appear raw in a URL. Percent-encoding converts each such character to its UTF-8 bytes, each written as a percent sequence, so the address carries the text correctly. Both the query-value and full-URL modes handle this, and the choice between them depends on whether the text is a value or a whole address.
Learning the difference between the encoding functions
Encoding the sample address in all three modes, side by side, is the clearest possible lesson in what each function does. The full-URL result stays readable, the query-value result encodes the structure characters, and the form result shows plus signs for spaces. Seeing the same input treated three ways teaches the distinction faster than reading function documentation.
Tips and Best Practices
- Encode values, not whole addresses, by default. When building a query string, encode each value separately and join them with ampersands and equals signs yourself. Encoding the assembled string destroys the structure.
- Never encode twice. Encoding an already-encoded value turns each percent sign into an encoding of itself. If output contains the sequence percent-two-five, it has probably been encoded twice. Decode once and start over.
- Use form mode only for form data. Plus signs for spaces belong to the form-encoded format. In an ordinary link, a plus sign in a query value may be read literally, so the query-value mode is safer there.
- Test the encoded result in a browser. Paste an encoded address into the address bar and confirm it loads the right page. A quick test catches mode mistakes before they reach users.
- Decode to verify. The JS URL Decoder reverses the encoding. A round trip that returns the original text confirms the encoding was correct and complete.
- Remember that encoding is not security. Percent-encoding makes text safe for transport; it does not hide it, and it does not make untrusted input safe to execute or to place in a page without further care.
Limitations
The encoder applies one mode to the whole input. It does not parse an address into parts and encode each part appropriately, so encoding a whole address in query-value mode will encode its structure, and encoding a single value in full-URL mode will leave structural characters unescaped. Choosing the mode is your responsibility, and the labels and hint exist to guide that choice. The tool also does not validate the input as an address, check that a host exists, or normalize an address: it encodes the characters it is given, nothing more.
The tool encodes one input at a time and does not build complete query strings from multiple values: assembling keys and values remains a manual or programmatic step. It does not decode, so verifying output requires the companion decoder. Finally, encoding output is deterministic given the mode, but different systems may parse the result slightly differently, particularly around plus signs in query strings, so testing against the actual receiving system remains good practice.
Frequently Asked Questions
Which mode should I use for a search term in a link?
Use encodeURIComponent, the query-value mode. It encodes spaces, ampersands, and other structural characters in the term, so the term arrives as a single value. Encode each value separately, then assemble the query string.
Which mode should I use for a complete address?
Use encodeURI, the full-URL mode. It encodes invalid characters such as spaces and non-ASCII letters while leaving the address structure intact, so the result is still a working address.
What is the difference between the query-value mode and form mode?
Form mode is the query-value encoding with encoded spaces replaced by plus signs, matching the form submission convention. Use it for form-encoded data, and use the query-value mode for ordinary links and query values.
Why does my output contain percent-two-five sequences?
That sequence is the encoding of a percent sign, and it usually means the input was already encoded and got encoded again. Decode once to recover the single-encoded form, and encode only unencoded input.
Does the encoder handle non-English text?
Yes. Non-ASCII characters are converted to UTF-8 bytes, and each byte becomes a percent sequence. Decoding the result returns the original text exactly.
Is my input uploaded anywhere?
No. Encoding runs entirely in your browser using built-in functions, and nothing is sent to a server.
Related Tools
These tools reverse the encoding and handle the neighboring formats for text in transit.
- JS URL Decoder – decode percent-encoded text back to its original characters, with an option for form data.
- URL Encoder – the general URL encoding tool in the Developer category.
- JS Base64 Encoder – encode text as Base64 when a restricted alphabet is needed instead of percent-encoding.
- JS HTML Entity Tool – escape text for safe placement in HTML, a different encoding for a different context.
- QR Code Generator – turn an encoded address into a code that can be scanned and opened directly.