URL Encoder & DecoderSpecialized Version
🔗

Percent Encoding Tool

Percent encoding

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

Percent Encoding Tool

Encode and decode text using percent encoding with our free online tool. Percent encoding (also called URL encoding) represents characters as %XX hexadecimal values, enabling safe transmission of any character through URL-restricted contexts.

Percent Encoding Reference

Hex ValueCharacterCategory
%00-%1FControl charsNon-printable
%20SpaceWhitespace
%21!Reserved in some contexts
%22"Unsafe
%23#Fragment delimiter
%25%Encoding character itself
%2F/Path delimiter
%3F?Query delimiter

RFC 3986 Character Classes

The URL specification defines these character categories:

  • Unreserved (never encoded): A-Z, a-z, 0-9, - . _ ~
  • Reserved (encoded when not delimiters): : / ? # [ ] @ ! $ & ' ( ) * + , ; =
  • Unsafe (always encoded): spaces, <, >, {, }, |, \, ^, , and non-ASCII

Percent Encoding Implementation

`javascript function percentEncode(text, options = {}) { const { encodeReserved = true, charset = 'utf-8' } = options;

// Convert to UTF-8 bytes const encoder = new TextEncoder(); const bytes = encoder.encode(text);

// Unreserved characters per RFC 3986 const unreserved = /[A-Za-z0-9\-._~]/;

let encoded = ''; for (const byte of bytes) { const char = String.fromCharCode(byte); if (unreserved.test(char)) { encoded += char; } else { encoded += '%' + byte.toString(16).toUpperCase().padStart(2, '0'); } }

return { encoded, byteCount: bytes.length, encodedLength: encoded.length }; }

// Strict RFC 3986 encoding function rfc3986Encode(text) { return encodeURIComponent(text).replace(/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase() ); } ``

Percent Encoding Standards

Different systems use slightly different percent encoding rules. Our tool supports RFC 3986 (URIs), HTML5 form encoding, and legacy encodings. Understanding which standard applies helps prevent encoding issues in your applications.

Frequently Asked Questions

What is percent encoding?

Percent encoding represents characters as %XX where XX is the hexadecimal value of the character byte. For example, space (ASCII 32 = hex 20) becomes %20. This allows any character to be safely transmitted in contexts that only support a limited character set, like URLs.

Why is it called percent encoding?

The name comes from the percent sign (%) used as the escape character. Each encoded byte is represented as % followed by two hexadecimal digits. This makes the encoding self-describing and easy to recognize in URLs and other text.

What is the difference between percent encoding and Base64?

Percent encoding keeps readable characters intact and only encodes problematic ones (minimal overhead for mostly-ASCII text). Base64 encodes everything uniformly as A-Z, a-z, 0-9, +, / with 33% size increase. Use percent encoding for URLs; use Base64 for binary data.

Related Tools

Explore other tools you might find useful:

Related Calculators