Developer

encodeURI vs encodeURIComponent: Which One to Use

URLs can only contain a limited set of characters. How percent-encoding works, the difference between encoding a whole URL and a single component, and the mistakes that break links. Applying these recommended techniques ensures high visual quality, faster page load speeds, and reliable performance across modern desktop and mobile web browsers.

Awais 2 min readPublished
encodeURI vs encodeURIComponent: Which One to Use

URLs can only contain a limited set of characters. Spaces, ampersands, question marks, and non-ASCII letters all have special meaning or are simply not allowed. Percent-encoding, often called URL encoding, solves this by replacing unsafe characters with a % followed by two hexadecimal digits. The ToolOrbit URL Encode / Decode tool makes this reliable and lets you choose the right scope for the job.

How percent-encoding works

Each byte that is not allowed in a URL is converted to its hexadecimal value preceded by a percent sign. A space becomes %20, an ampersand becomes %26, and a non-ASCII character is first encoded as UTF-8 bytes, each of which is then percent-encoded. Decoding simply reverses the process.

hello world & friends
->
hello%20world%20%26%20friends

cafe (UTF-8 accent) -> ca%C3%A9

Component vs full URL encoding

This is the single most important distinction. When you encode a value that will sit inside a query parameter, you must encode reserved characters like &, =, ?, and / so they do not change the structure of the URL. When you have an already-assembled URL and only want to fix spaces and illegal characters, you must leave those structural characters intact.

  • Component mode (like encodeURIComponent): use for individual query values, path segments, or form fields
  • Full URL mode (like encodeURI): use for an entire URL where the structure is already correct
  • Always encode user input as a component before stitching it into a query string
  • Never double-encode: encoding an already-encoded string turns % into %25
Warning: Encoding a whole URL when you meant to encode just one parameter is the top cause of broken links. If your & separators vanish, you used the wrong mode.

Using the tool

Paste your text, pick component or full URL mode, and switch between encode and decode. Everything happens locally in your browser, so internal URLs and tokens never leave your machine. Decode mode is handy for reading the real values behind a long, percent-heavy analytics link.

Best practices

Encode early and decode late: encode each value the moment you place it into a URL, and decode only when you read it back. When in doubt, treat every dynamic value as a component. This keeps your URLs valid, your query parameters intact, and your redirects working as intended.

The line between encode(whole URL) and encode(part)

In JavaScript, encodeURI() leaves structural characters (/, :, ?, &, =) alone so a whole URL survives; encodeURIComponent() encodes even those, so a single value is safe to embed in an already-valid URL. Getting this backwards is the classic “why is my query broken” bug: encode the path using the first, encode values using the second. Test the finished link in the tool before shipping it — a percent-encoded URL that fails pasting into a client is still failure.

Reserved-looking text that must reach the API literally (like “50% off” or a plus sign in a search term) has to be encoded — an unencoded % or + is interpreted, not transmitted.

Tools mentioned

More reading

View all guides
Free Developer Tools Online: 2026 Developer Toolkit & Guides
Developer

Free Developer Tools Online: 2026 Developer Toolkit & Guides

Explore 30+ free browser-based developer tools: JSON formatters, Base64 converters, cron generators, regex testers, SQL formatters, and hash generators.

3 min readPublished
CSS Border Radius: 15 Copy-Paste Examples
Developer

CSS Border Radius: 15 Copy-Paste Examples

15 modern CSS border radius examples: rounded cards, pills, circle avatars, asymmetrical organic blobs, and fancy 8-value border radius shapes.

3 min readPublished
Percent Encoding Reference Table (Every Character)
Developer

Percent Encoding Reference Table (Every Character)

Complete percent encoding ASCII reference table: quick lookup for spaces, slashes, ampersands, punctuation, and UTF-8 special characters in URLs.

3 min readPublished
URL Encoding Explained: %20 vs +, Reserved Characters & Rules
Developer

URL Encoding Explained: %20 vs +, Reserved Characters & Rules

Complete guide to percent encoding in URLs: learn when to use %20 vs +, how reserved characters like & and ? work, and how to avoid encoding bugs.

3 min readPublished
Cron Every Hour, Day & Midnight: All Daily Schedules
Developer

Cron Every Hour, Day & Midnight: All Daily Schedules

Master standard daily cron schedules: cron every hour, every day at midnight, twice a day, and custom hourly intervals with copy-paste examples.

4 min readPublished
Cron Expression Cheat Sheet — Copy-Paste Schedule Examples
Developer

Cron Expression Cheat Sheet — Copy-Paste Schedule Examples

Free cron expression cheat sheet with copy-paste examples for every 5 minutes, hourly, daily at midnight, weekdays only, and more.

5 min readPublished
Cron Every 10 Minutes — Syntax, Examples and Best Practices
Developer

Cron Every 10 Minutes — Syntax, Examples and Best Practices

Use the cron expression */10 * * * * to run jobs every 10 minutes, plus examples for common schedules and troubleshooting tips.

3 min readPublished
Why CSV Is Tricky to Parse: Delimiters, Quotes and Headers
Developer

Why CSV Is Tricky to Parse: Delimiters, Quotes and Headers

Why CSV files are harder to read correctly than they look, how to choose the right JSON shape, and the mistakes to avoid.

2 min readPublished