URL Encoder & Decoder — Percent-Encode URLs Online

This free URL encoder and decoder converts text to and from percent-encoding so it travels safely inside a URL. Reserved and unsafe characters — spaces, ampersands, question marks, and non-Latin letters — must be encoded as a percent sign followed by their hex byte value, or a query string can break. It mirrors JavaScript's encodeURIComponent for values and encodeURI for whole URLs, the distinction that trips most developers. Everything runs locally in your browser, so the data you encode is never uploaded.

How URL encoding works

URL encoding (also called percent-encoding) converts characters that are not allowed or have special meaning in URLs into a safe format. Each unsafe character is replaced by a percent sign (%) followed by its two-digit hexadecimal ASCII code. For example, a space becomes %20, the # symbol becomes %23, and & becomes %26.

This tool uses JavaScript's encodeURIComponent(), which encodes everything except A–Z, a–z, 0–9, and the characters - _ . ! ~ * ' ( ). This is the correct function for encoding individual query parameters or path segments. The related function encodeURI() is less strict and preserves characters like / ? # & that have structural meaning in a full URL. Decoding uses the corresponding decodeURIComponent(). Double-encoding is a common mistake — encoding an already-encoded string turns %20 into %2520, which breaks URLs. Always decode first if your string might already be encoded.

Related tools

Base64 → Slug generator → JSON formatter →

What percent-encoding solves

URLs may only contain a limited ASCII set, so any reserved or unsafe character — spaces, ?, &, #, non-Latin letters — must be percent-encoded as % followed by its hex byte value. A space becomes %20, an ampersand %26. Without this, a query value containing & would be misread as the start of a new parameter and silently corrupt your data.

encodeURIComponent vs encodeURI

JavaScript exposes two functions and choosing wrong is a classic bug. encodeURIComponent() escapes almost everything and is correct for a single value you're dropping into a query string. encodeURI() leaves structural characters like : / ? & = intact and is meant for encoding a whole URL. Use the component version for parameter values; the full version only when assembling an entire address.

Form encoding gotcha

HTML form submissions encode spaces as + rather than %20. When decoding such data you must convert + back to a space first — a step plain URL decoders skip, which is why pasted form data sometimes shows stray plus signs.

⚠️ Common Mistakes to Avoid

Frequently asked questions

What is URL encoding?

It is a mechanism for encoding information in a Uniform Resource Identifier (URI) by replacing 'unsafe' characters with % followed by two hex digits.

Why do I need to encode URLs?

URLs can only contain a limited set of ASCII characters; special symbols like spaces, &, or ? need to be encoded to avoid breaking the URL.

Reviewed by the ToolsmithPro editorial team · Last updated June 2026. Every calculation and conversion runs entirely in your browser — your inputs are never uploaded, stored or shared. Formulas and methodology are documented on our about page; spot an error? tell us and we'll fix it.