URL Decoder

Decode URL encoded text back to its original form

Convert URL encoded text back to its original form. This tool is useful for decoding URLs, query parameters, or other web content that has been encoded for transmission.

URL Encoded Input

Decoded Output

decodeURIComponent

Decode your URL encoded text to see results

URL Decoding Examples

Query Parameters

Encoded: search?query=how%20to%20build%20websites
Decoded: search?query=how to build websites

Spaces in search queries are encoded as %20 and need to be decoded for processing.

Special Characters

Encoded: product?name=T%26T%20Special%232
Decoded: product?name=T&T Special#2

Special characters like &, #, and spaces are decoded back to their original form.

International Characters

Encoded: location=M%C3%BCnchen
Decoded: location=München

UTF-8 encoded characters are decoded back to their original Unicode characters.

Form Data

Encoded: email=user%40example.com
Decoded: email=user@example.com

Email addresses with @ symbols need decoding when passed as URL parameters.

Complex Query Strings

Encoded: filters=status%3Aactive%2Cdate%3E2023-01-01
Decoded: filters=status:active,date>2023-01-01

Complex filter expressions with special characters require proper decoding.

File Paths

Encoded: download?file=My%20Document%20(v2).pdf
Decoded: download?file=My Document (v2).pdf

File names with spaces and special characters need decoding for proper handling.

JSON Data in URLs

Encoded: data=%7B%22name%22%3A%22John%22%2C%22age%22%3A30%7D
Decoded: data={"name":"John","age":30}

JSON objects passed as URL parameters require decoding to parse correctly.

Social Media Content

Encoded: share?text=Check%20this%20out%21%20%F0%9F%9A%80
Decoded: share?text=Check this out! 🚀

Social sharing content with emojis and punctuation needs proper decoding.

API Endpoints with Parameters

Encoded: api%2Fv1%2Fusers%3Ffilter%3Dname%3A%22John%20Doe%22
Decoded: api/v1/users?filter=name:"John Doe"

API endpoints passed as parameters often need decoding for proper routing.

Error Messages

Encoded: error=Invalid%20input%3A%20%22username%22%20is%20required
Decoded: error=Invalid input: "username" is required

Error messages in URLs need decoding for proper display to users.

Database Queries

Encoded: query=SELECT%20*%20FROM%20users%20WHERE%20age%20%3E%2018
Decoded: query=SELECT * FROM users WHERE age > 18

SQL queries passed via URL need decoding before execution.

Base64 URLs

Encoded: token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9%2E...
Decoded: token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9....

Base64 encoded tokens in URLs may contain encoded characters that need decoding.

⚠️ Common Pitfalls to Avoid:

  • Double Decoding: Don‘t decode text that‘s already been decoded
  • Wrong Method: Use decodeURIComponent() for parameters, decodeURI() for full URLs
  • Plus Signs: Replace + with %20 before decoding if needed
  • Error Handling: Always wrap decode operations in try-catch blocks
  • Validation: Validate decoded output before using it in your application

💡 Pro Tips:

  • • Test with various character sets including international characters
  • • Use browser developer tools to inspect URL parameters
  • • Consider using a URL parsing library for complex scenarios
  • • Always sanitize decoded data before using it in databases or display
  • • Keep a reference of common percent-encoded characters handy

About URL Decoding

URL decoding is the process of converting percent-encoded characters back to their original form. This is often needed when processing data from query strings, form submissions, or any other URL-encoded data.

When URLs contain special characters, spaces, or non-ASCII characters, they are encoded using percent-encoding (e.g., a space becomes %20). URL decoding transforms these encoded sequences back to their original characters.

JavaScript provides two built-in functions for URL decoding: decodeURI() for complete URLs and decodeURIComponent() for URL components like query parameters.

Common URL Decoding Issues

  • Invalid Sequences: Incorrectly formatted percent-encoded sequences (e.g., %2G instead of %2C) will cause decoding errors.
  • Wrong Decoding Method: Using decodeURI() when decodeURIComponent() is needed can leave some characters still encoded.
  • Double Decoding: Decoding text that has already been decoded can cause unexpected results or errors.
  • Plus Signs: Some server-side frameworks convert spaces to + instead of %20, which isn‘t automatically converted by JavaScript‘s decoding functions.

Understanding URL Decoding

Why is URL Decoding Important?

URL decoding is essential for web development when you need to process data that has been URL-encoded for transmission. This commonly occurs when handling form submissions, query parameters, API responses, and data from external sources.

Data Processing: Extract original values from encoded query parameters

Form Handling: Process form data that has been URL-encoded

API Integration: Handle encoded data from external APIs

Log Analysis: Decode URLs in server logs for analysis

decodeURI vs. decodeURIComponent

decodeURI()

  • Decodes a complete URI
  • Does not decode reserved characters: ; / ? : @ & = + $ , #
  • Use when decoding full URLs
  • Safer for URLs that should remain functional
  • Example: https://example.com/path%20with%20spaces

decodeURIComponent()

  • Decodes URI components like parameters
  • Decodes all percent-encoded characters
  • Use for individual parameter values
  • More thorough decoding
  • Example: name%3DJohn%26age%3D30name=John&age=30

Common Decoding Scenarios

Query Parameter Processing

When extracting values from URL query strings, you often need to decode them to get the original user input. This is essential for search queries, form data, and user preferences passed via URLs.

?search=web%20development → search=web development

Form Data Handling

Form submissions using GET method or AJAX often URL-encode the data. Decoding is necessary to process user input correctly on the server side.

name=John%20Doe&email=user%40example.com

API Response Processing

Some APIs return URL-encoded data, especially when dealing with user-generated content or data that might contain special characters.

title=Hello%20World%21&content=Check%20this%20out%3A%20...

Error Handling and Troubleshooting

Invalid Percent Encoding

Malformed sequences like %2G or incomplete sequences like %2 will cause decoding errors. Always validate input before decoding.

Plus Sign Handling

Some systems encode spaces as + instead of %20. JavaScript‘s decode functions don‘t handle this automatically. You may need to replace + with %20 before decoding.

Double Encoding Detection

Sometimes data gets encoded multiple times. Check if decoded output still contains percent-encoded sequences that might need another round of decoding.

Best Practices

Choose the right method: Use decodeURIComponent() for parameters, decodeURI() for full URLs

Handle errors gracefully: Wrap decoding operations in try-catch blocks

Validate input: Check for malformed percent-encoded sequences before decoding

Consider plus signs: Replace + with %20 if dealing with form-encoded data

Avoid double decoding: Check if input is already decoded before processing

Security considerations: Validate and sanitize decoded output before use

Real-World Applications

Web Development

  • Processing search queries from URLs
  • Handling form submissions via GET
  • Extracting user preferences from URLs
  • Processing deep linking parameters

Data Analysis

  • Analyzing web server access logs
  • Processing user behavior tracking data
  • Extracting search terms from referrer URLs
  • Cleaning up encoded data exports