ToolWren logo ToolWren
ToolWrenGuides › URL Encoding Explained (Percent-Encoding and When to Use It)

URL Encoding Explained (Percent-Encoding and When to Use It)

Encoding · Developers · Updated 14 August 2026

Ever seen %20, %3D or + in a web address and wondered what they mean? That is URL encoding — also called percent-encoding — and it is what lets URLs safely carry spaces, accents and symbols. Here is how it works.

Why URLs need encoding

URLs are only allowed to contain a limited set of characters. Anything outside that set — spaces, most punctuation, non-English letters — must be escaped so it does not break the address or get misinterpreted. URL encoding replaces each unsafe byte with a % followed by its two-digit hexadecimal value. A space becomes %20, an equals sign becomes %3D, and an ampersand becomes %26. Try it on our URL encoder/decoder.

Reserved vs unreserved characters

Some characters have special meaning in a URL — ? starts the query string, & separates parameters, / separates path segments, and # marks a fragment. These are reserved: if you want them as literal data rather than structure, they must be encoded. Letters, digits, and a few symbols like -, _, . and ~ are unreserved and never need escaping.

Encoding a whole URL vs a component

There is an important distinction. When encoding an entire URL you must keep the structural characters (:, /, ?, &) intact. But when encoding a single value — say a search term you are dropping into a query string — you should escape those characters too, so they are treated as data. Getting this wrong is a classic source of broken links and mangled parameters; the URL tool handles component encoding for you.

URL encoding is not Base64

People sometimes confuse the two. Base64 represents arbitrary binary data as text and expands it by about a third. URL encoding only escapes the unsafe characters in otherwise-text data and leaves everything else readable. Use URL encoding for query strings and form data; use Base64 for embedding binary blobs. Neither provides any security.

A related task: clean URL slugs

If you are building readable web addresses, you usually want a slug — lowercase, hyphenated, no special characters — rather than a percent-encoded mess. Our slug generator turns "My First Blog Post!" into my-first-blog-post, which is friendlier for both users and search engines. Everything runs in your browser.

Tools used in this guide

More guides