Back to Blog
Converters4 min read

URL Encoding Complete Guide

Understand percent encoding and learn when to use encodeURI vs encodeURIComponent.

What is URL Encoding?

URL encoding (percent encoding) replaces unsafe characters with a % followed by their hex value. This ensures URLs are valid and can be transmitted safely.

Original:
hello world & goodbye
Encoded:
hello%20world%20%26%20goodbye

encodeURI vs encodeURIComponent

encodeURI

For complete URLs

Preserves: ; / ? : @ & = + $ , #

encodeURIComponent

For query parameter values

Encodes ALL special characters

Avoid Double Encoding

A common mistake is encoding an already-encoded string, turning %20 into %2520.

Always decode first if you're unsure whether input is already encoded.

Try Our URL Encoder

Smart encoding detection, URL parser, and query string builder.

Open URL Encoder

Written by AI AutoSite Team • Last updated 2025-12-04