CS

Loading workspace...

Preparing your tools

Guide

URL-Encode Query Values Without Breaking Links

Percent-encode a query value with browser component encoding, handle Unicode and avoid encoding entire URLs or double encoding.

Introduction

Introduction

A URL has structural characters such as ?, &, = and /. Those characters should not be confused with the value of a query parameter. URL Encode uses JavaScript's encodeURIComponent behavior on one pasted text component in the browser. This makes it useful when building a search link, redirect parameter or API query string that includes spaces and punctuation.

Do not run an entire URL through a component encoder if you intend its separators to keep their normal meaning. Encode the individual value, then add the structural separators yourself.

Step-by-step guide

1

Step 1

Open [URL Encode](/tools/url-encode).

2

Step 2

Paste the phrase `red shoes & boots` as the value to encode.

3

Step 3

Run the action and review the percent-encoded output.

4

Step 4

Append the encoded value after a known query key, for example `?q=`, in the destination URL.

5

Step 5

Open the completed test URL and verify that the application receives the original phrase as one parameter.

Benefits

  • ✓ Encode values individually, not the complete structural URL.
  • ✓ Keep a clear distinction between query strings, form encoding and path segments.
  • ✓ Validate redirect destinations separately; encoding does not make them safe.
  • ✓ Test Unicode and punctuation through the actual receiving application.
  • ✓ Never put secret credentials into public demo links.

Best practices

  • • Encode values individually, not the complete structural URL.
  • • Keep a clear distinction between query strings, form encoding and path segments.
  • • Validate redirect destinations separately; encoding does not make them safe.
  • • Test Unicode and punctuation through the actual receiving application.
  • • Never put secret credentials into public demo links.

More details

Encode a sample search phrase

  1. Open URL Encode.
  2. Paste the phrase red shoes & boots as the value to encode.
  3. Run the action and review the percent-encoded output.
  4. Append the encoded value after a known query key, for example ?q=, in the destination URL.
  5. Open the completed test URL and verify that the application receives the original phrase as one parameter.

The ampersand in the source phrase must not be treated as a separator between two different parameters. Encoding the value protects that distinction. The tool is limited to text components, not full URL validation.

Unicode and percent sequences

Non-ASCII text is encoded into UTF-8 byte sequences before percent encoding. An accented letter may therefore turn into several %HH groups. Percent encoding is not encryption or anonymization; a server can decode the original characters on request.

A plus sign and a space are not interchangeable in all URL contexts. The standard component encoder uses %20 for a space; form submissions using application/x-www-form-urlencoded may use + for spaces instead. Verify the exact protocol expected by the receiver.

Query values versus path segments

A value destined for a path segment should be encoded according to that API's contract. If an input contains a slash, component encoding prevents it from being interpreted as an additional path separator. But encoding an entire route or already-encoded segment can lead to double encoding, for example turning a literal percent sign into %25.

For the reverse task, use URL Decode to inspect a pasted encoded component. A decoded result is still just text; any link or redirect that uses it should be validated against authorized destinations.

Troubleshooting

If the server sees two query parameters instead of one, a reserved character may have been left unencoded. If the output contains %25, check whether you encoded a value that already contained percent escapes. When authentication callbacks fail, inspect the required exact redirect URL rather than repeatedly encoding it without knowing the service's rules.

Related tools

Continue your workflow with these matching tools.

Related, practical walkthroughs for the tools used in this guide.

Ready to run this workflow?

Upload your file and apply these settings in under a minute.