DeveloperApril 2026 Β· 5 min read

How to URL Encode and Decode Strings

URL encoding (also called percent encoding) replaces unsafe characters with a % followed by their hexadecimal value. Spaces become %20, ampersands become %26, and non-ASCII characters like Γ© become %C3%A9. This encoding is required whenever you include user input, special characters, or non-ASCII text in URLs and query strings.

πŸ”—
Try the URL Encoder
Free, no signup
β†’
DG
Derek Giordano
Designer & Developer
In this guide
01What Gets Encoded02URL Encoding in JavaScript03Decoding Percent-Encoded Strings04Common Encodings Reference
⚑ Key Takeaways
  • Encode special characters for URLs and decode percent-encoded strings.
  • What Gets Encoded.
  • Covers url encoding in javascript.
  • Covers decoding percent-encoded strings.
  • Covers common encodings reference.

What Gets Encoded

Characters that have special meaning in URLs must be encoded when used as data: & (parameter separator), = (key-value separator), ? (query string start), # (fragment identifier), / (path separator), + and spaces. Non-ASCII characters (accented letters, emoji, CJK characters) are always encoded. The URL Encoder handles all of these β€” paste any string and get the encoded output.

URL Encoding in JavaScript

JavaScript provides two functions: encodeURIComponent() encodes a value for use as a query parameter β€” it encodes everything except letters, digits, and - _ . ~. encodeURI() encodes a full URL but preserves structural characters like : / ? # @. Use encodeURIComponent() for parameter values: '?search=' + encodeURIComponent(userInput). Use encodeURI() for complete URLs.

πŸ’‘ Tip
Use 3+ color stops instead of 2 to avoid the muddy gray band that appears in the center of complementary-color gradients.

Decoding Percent-Encoded Strings

Decoding reverses the process: %20 becomes a space, %26 becomes &, %C3%A9 becomes Γ©. In JavaScript: decodeURIComponent('%C3%A9') returns 'Γ©'. The URL Encoder tool also decodes β€” paste a percent-encoded string and get the original text back.

⚠ Warning
CSS gradients used as backgrounds cannot be animated with standard transitions. Use background-size animation or @property registered custom properties instead.

Common Encodings Reference

Space: %20 (or + in form data). &: %26. =: %3D. ?: %3F. #: %23. /: %2F. @: %40. +: %2B. %: %25. Non-ASCII characters use UTF-8 byte sequences: Γ© = %C3%A9, Γ± = %C3%B1, ΓΌ = %C3%BC.

Frequently Asked Questions

What is URL encoding?+
URL encoding replaces special characters with percent-encoded equivalents (%20 for space, %26 for &) so they can be safely included in URLs without being interpreted as structural characters.
When do I need to URL encode?+
Whenever you include user input in a URL, when query parameter values contain special characters, and when URLs contain non-ASCII characters (accented letters, emoji).
What is the difference between encodeURI and encodeURIComponent?+
encodeURI preserves URL structural characters (: / ? # @) and is used for complete URLs. encodeURIComponent encodes everything except letters and digits, and is used for individual parameter values.
Try it yourself

Use the URL Encoder β€” free, no signup required.

⚑ Open URL Encoder
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.