URL Encoder & DecoderSpecialized Version
🔗

Query String Encoder

Encode query strings

Tip: Use encodeURIComponent for query parameter values. Use encodeURI only for full URLs where you want to preserve : / ? & characters.
Common URL Encodings Reference
%20
!%21
"%22
#%23
$%24
&%26
'%27
+%2B
,%2C
/%2F
:%3A
?%3F
@%40
=%3D

Query String Encoder

Format key-value pairs for URL query strings. Properly encode both keys and values for safe URL inclusion.

Query String Format

`` https://example.com/search?q=hello+world&sort=date&page=1 └──────── query string ────────┘ `

Query String Encoding

`javascript // Using URLSearchParams (recommended) function encodeQueryString(params) { const searchParams = new URLSearchParams(); for (const [key, value] of Object.entries(params)) { searchParams.append(key, value); } return searchParams.toString(); }

// Example encodeQueryString({ q: 'hello world', filter: 'price>100' }); // "q=hello+world&filter=price%3E100" `

Handling Arrays

`javascript // Multiple values for same key const params = new URLSearchParams(); ['red', 'blue', 'green'].forEach(color => { params.append('colors', color); }); // colors=red&colors=blue&colors=green ``

Use this encoder to build properly formatted query strings.

Frequently Asked Questions

What is a query string?

A query string is the part of a URL after ? containing key-value pairs. Parameters are separated by & and keys/values by =. Example: "?page=1&sort=date".

How do I pass arrays in query strings?

Use repeated keys: colors=red&colors=blue. Or comma-separated: colors=red,blue. Or brackets: colors[]=red. The format depends on your server.

What characters are safe in query strings?

Only A-Za-z0-9 and -_.~ are safe without encoding. All other characters including spaces, &, and = should be percent-encoded.

Related Tools

Explore other tools you might find useful:

Related Calculators