CalcPro

URL Encode / Decode

Percent-encode text for URLs or decode an encoded string.

How it works

This tool converts between plain text and percent-encoded format, which is the standard way to safely represent special characters and spaces in URLs. When you encode, unsafe characters are replaced with a percent sign and their hexadecimal ASCII or UTF-8 byte value. When you decode, those percent sequences are converted back to their original characters.

The formula

Encoded = "%" + hex(byte value of character) for each unsafe character; all safe characters pass through unchanged.

Worked example

Let's encode the text: Hello, World! How are you?

Step 1: Identify unsafe characters.

  • The comma (,), space, exclamation mark (!), and question mark (?) are unsafe.
  • Letters, numbers, and the hyphen are always safe.

Step 2: Replace each unsafe character with %HH (where HH is its hex code).

  • Comma = ASCII 44 = hex 2C → %2C
  • Space = ASCII 32 = hex 20 → %20
  • Exclamation = ASCII 33 = hex 21 → %21
  • Question mark = ASCII 63 = hex 3F → %3F

Step 3: Reconstruct the string.

  • H → H
  • e → e
  • l → l
  • l → l
  • o → o
  • , → %2C
  • (space) → %20
  • W → W
  • o → o
  • r → r
  • l → l
  • d → d
  • ! → %21
  • (space) → %20
  • H → H
  • o → o
  • w → w
  • (space) → %20
  • a → a
  • r → r
  • e → e
  • (space) → %20
  • y → y
  • o → o
  • u → u
  • ? → %3F

Result: Hello%2C%20World%21%20How%20are%20you%3F

To decode it, you'd reverse the process: every %HH becomes its corresponding character, and everything else stays as-is.

Non-ASCII example: If you encode café, the é (U+00E9) is UTF-8 encoded as bytes C3 A9, becoming caf%C3%A9.

Common mistakes

Forgetting the forward slash: In URL paths, the forward slash (/) is often safe and shouldn't be encoded—encoding it to %2F breaks navigation. This calculator preserves / by default in most contexts, but check your specific use case.

Double-encoding: If you encode text that's already encoded, you'll get %252C instead of %2C (the % itself gets encoded). Only encode once.

Assuming all symbols are encoded: The hyphen (-), underscore (_), period (.), and tilde (~) don't need encoding and won't be touched. Only unsafe characters are converted.

Mismatched character sets: If the source text uses a different encoding (like Latin-1 instead of UTF-8), decoding may produce garbled output. Always verify the original encoding matches UTF-8.

Frequently asked questions

What is URL encoding?

URL encoding (also called percent encoding) converts special characters into a format safe for transmission in URLs. Each unsafe character becomes a percent sign followed by two hexadecimal digits representing its ASCII value. For example, a space becomes %20.

When do I need to encode URLs?

Encode URLs when passing user input as query parameters, building links with special characters, or embedding data in URLs. Characters like spaces, &, ?, #, and non-ASCII letters must be encoded to avoid breaking the URL structure or losing data.

Can I decode any percent-encoded string?

Yes, this calculator decodes any valid percent-encoded string back to readable text. If the input isn't properly encoded, the decoder will either return it unchanged or flag invalid sequences (like %ZZ).

Which characters need encoding?

Reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =), unsafe characters (space, ", <, >, %), and non-ASCII characters all require encoding. Letters, digits, hyphens, underscores, periods, and tildes are safe and don't need encoding.

Is URL encoding the same as HTML encoding?

No. URL encoding is for safely embedding data in URLs. HTML encoding protects special characters in web page content. They use different rules—for example, a space is %20 in URLs but &nbsp; or &#32; in HTML.

What about Unicode and non-English text?

Non-ASCII characters (accents, Cyrillic, Chinese, etc.) are first converted to UTF-8 bytes, then each byte is percent-encoded. For example, é becomes %C3%A9. The decoder reverses this process automatically.