🛠️DevTools

Encode SQL Queries for URL Transmission

Type:
Try:
49 chars
69 chars(10 encoded)
Size change: +40.8%
URL Encoding Reference
%20
Space
&%26
Ampersand
=%3D
Equals
?%3F
Question mark
/%2F
Forward slash
#%23
Hash
+%2B
Plus
@%40
At sign
encodeURI vs encodeURIComponent

encodeURIComponent: Encodes all special characters including /, ?, &, =, #. Use for encoding URL parameter values.

encodeURI: Preserves URL structure characters (/, ?, &, =, #, :). Use for encoding entire URLs while keeping them valid.

encodeURIComponent("a=b&c=d") → "a%3Db%26c%3Dd"
encodeURI("a=b&c=d") → "a=b&c=d" (unchanged)

Code Examples

Here's how to achieve this in different programming languages:

1// URL Encode
2const input = "SELECT * FROM users WHERE name='John' AND age>=30";
3const encoded = encodeURIComponent(input);
4console.log(encoded); // "SELECT%20*%20FROM%20users%20WHERE%20name%3D'John'%20AND%20age%3E%3D30"
5
6// URL Decode
7const decoded = decodeURIComponent("SELECT%20*%20FROM%20users%20WHERE%20name%3D'John'%20AND%20age%3E%3D30");
8console.log(decoded); // "SELECT * FROM users WHERE name='John' AND age>=30"

Frequently Asked Questions

What is the URL encoding of "SELECT * FROM users WHERE name='John' AND age>=30"?

The URL encoding of "SELECT * FROM users WHERE name='John' AND age>=30" is "SELECT%20*%20FROM%20users%20WHERE%20name%3D'John'%20AND%20age%3E%3D30". URL encoding converts special characters to percent-encoded format using %XX hexadecimal values.

How do I URL encode text?

Use encodeURIComponent() in JavaScript, urllib.parse.quote() in Python, or Uri.EscapeDataString() in C#. Our online tool above encodes instantly.

How do I decode URL-encoded text?

Use decodeURIComponent() in JavaScript, urllib.parse.unquote() in Python, or Uri.UnescapeDataString() in C#.

Why do spaces become %20?

The hex value of space (ASCII 32) is 20. URL encoding uses %XX format where XX is the hex value. So space → %20, @ → %40, & → %26.

What's the difference between encodeURI and encodeURIComponent?

encodeURIComponent encodes ALL special characters (/, ?, &, =) for use in URL parameter values. encodeURI preserves URL structure and is used for whole URLs.

More URL Examples

Related URL Tools

📚 Learn More