How to URL Encode a URL

If you have ever copied a link with a space in it, shared a search query, or built an API request, you have seen URLs break or behave unexpectedly. The fix is URL encoding. In this guide you will learn how to URL encode a URL, what percent-encoding actually does, when you must encode characters, and how to encode spaces, special characters, and whole query strings quickly and correctly.

What is URL Encoding (Percent-Encoding)

URL encoding, formally called percent-encoding, is a way to represent characters that are not safe in a URL. A URL is limited to a small set of characters that browsers, servers, and the internet in general can handle predictably. Anything outside that set must be rewritten.

An encoded character looks like a percent sign followed by two hexadecimal digits. The hex number is the byte value of the character in UTF-8. For example:

The safe set of characters that never need encoding are letters (A-Z, a-z), digits (0-9), and the symbols -, ., _, and ~. Everything else is a candidate for encoding.

When You Need to Encode a URL

You need to URL encode in several everyday situations.

Spaces and special characters

The most common offender is the space. Spaces are simply not allowed in a URL, so they are encoded as %20. If you have filenames with spaces — "my photo.jpg" — or text with symbols, encode them before sending.

Query strings

Query strings are the part of the URL after the ?. If a keyword you are searching for contains a space or a special character like & or =, you must encode it or your query will be misinterpreted. This is why search engines and analytics tools show long, dense URLs — the readable parts have been percent-encoded.

Unicode and emoji

Emoji, accented letters, and non-English text must be encoded so that links survive copy-paste, email, and messaging apps. Encoding turns them into a transport-safe string while keeping the meaning intact.

Fielding and form data

URL encoding is also fundamental to how online forms submit data. When you submit a form, every field value is percent-encoded before it reaches the server, so any text you type — spaces, symbols, quotes, newlines — arrives intact and unbroken.

Backend and API development

If you build or debug APIs, URL encoding is something you will handle constantly. Query parameters containing dates, IDs, filters, or array values all need correct encoding, and a single wrong character is enough to make a request fail silently or return unexpected results.

How to URL Encode Manually & With a Tool

You can encode a URL by hand, though it is tedious for anything long. Here is the manual method and the much faster tool-based one.

Manual encoding

1. Look up the character you want to encode. 2. Replace it with % followed by its two-digit hex byte value. 3. Leave letters, digits, and - . _ ~ alone. 4. Encode each value in a query individually, not the whole string, so that the separator characters ? and & stay readable.

If you are in a browser console, JavaScript helps: encodeURIComponent("hello world") returns hello%20world, and encodeURI(url) handles an entire URL while preserving the structural characters.

Encoding with a tool

For anything with more than a few characters, a URL encoder is far safer and faster. It avoids the tiny mistakes — a missed hex pair, an over-encoded ampersand, a broken query — that silently break links.

Use our free URL encoder to transform plain text into a safe, valid URL instantly. Paste your string, get the right percent-encoded output, and copy it straight into your browser, API call, or form field. No sign-up required.