Developer Tools · 5 min read · Updated 2026-11-20

encodeURI vs. encodeURIComponent vs. Form + Encoding & Query Parsing

Using encodeURI on a query parameter leaves &, =, and ? unencoded—corrupting query parsing—while running encodeURIComponent on a full URL breaks https:// slashes.

1. Choosing the Right Encoder for the Job

Use encodeURI when encoding an entire URL that has spaces or non-ASCII paths while preserving structural delimiters (:, /, ?, &, =). Use encodeURIComponent when encoding an individual query parameter value, redirect URL, or slug segment.

  • encodeURIComponent encodes /, ?, &, =, +, # (ideal for query values).
  • application/x-www-form-urlencoded encodes spaces as + rather than %20.

Try the Interactive Browser Tool

Compare encodeURIComponent, encodeURI, and form + encoding while parsing and editing URL query parameters.

Related Guides & Utilities