URL Encoder/Decoder

Percent-encode or decode a URL or query string.

Overview

Encodes reserved and non-ASCII characters into standard percent-encoded escape sequences (%XX) and decodes URL strings safely.

Formula & Calculation Method

Encoded_URL = encodeURIComponent(String) | Decoded_URL = decodeURIComponent(Encoded_String)

Replaces unsafe URI characters with a '%' symbol followed by two hexadecimal digits representing their UTF-8 byte values (e.g. space -> %20).

Worked Example: Encoding Query Parameter String

Inputs: Raw String: 'name=Rahul Sharma & co=Calciverse!'

  • Identify space characters and special symbols (&, =, !).
  • Encode spaces to %20 and special characters to corresponding hex triplets.
  • Resulting encoded string: 'name%3DRahul%20Sharma%20%26%20co%3DCalciverse!'

Summary: Plaintext = 'Rahul Sharma & co' | Encoded = 'Rahul%20Sharma%20%26%20co'

Common Use Cases

  • API Query Construction: Encode search parameters and user inputs before appending to GET request URL endpoints.
  • OAuth Redirect URIs: Safely pass callback URLs as query string values inside single-sign-on redirect parameters.
  • Webhook Payload Links: Prepare encoded URL links containing special characters for notification systems.

Frequently Asked Questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI preserves full URL structure (leaving ://, ?, & intact); encodeURIComponent encodes all reserved characters and is intended for individual query parameters.

Why is space encoded as %20 or +?

%20 is standard percent-encoding; the '+' character is used specifically in application/x-www-form-urlencoded form submissions.

What characters never need URL encoding?

Unreserved characters: alphanumeric letters (A-Z, a-z), decimal digits (0-9), and hyphen (-), underscore (_), period (.), and tilde (~).

Related Calculators & Tools