URL Decode API: Complete Developer Guide

Need to decode URL-encoded strings? This guide covers everything about URL decoding via API, including how percent encoding works, handling special characters, and implementation examples in multiple programming languages.

What is URL Decoding?

URL decoding (also called percent decoding) converts percent-encoded characters back to their original form. It reverses the URL encoding process, converting %XX sequences back to the characters they represent.

Example: Hello%20World%21 becomes Hello World!

How URL Decoding Works

The decoding process converts encoded sequences:

Percent Sequences

%20 becomes a space, %21 becomes !, %3F becomes ?

Plus Signs

In query strings, + is often decoded as a space (depends on context)

Multi-byte Characters

UTF-8 characters like %E2%9C%93 decode to special symbols

Security Note: Always validate and sanitize decoded input before using it in your application. Decoded strings may contain malicious content.

Using the URL Decode API

TinyFn provides a simple endpoint to decode URL-encoded strings:

API Request
POST https://api.tinyfn.io/v1/decode/url
Headers: X-API-Key: your-api-key
Content-Type: application/json

{
  "text": "Hello%20World%21%20How%20are%20you%3F"
}
Response
{
  "decoded": "Hello World! How are you?",
  "original": "Hello%20World%21%20How%20are%20you%3F",
  "encoding": "utf-8"
}

Parameters

Parameter Type Description
text string The URL-encoded string to decode (required)
plus_as_space boolean Decode + as space (default: true)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/decode/url',
  {
    method: 'POST',
    headers: {
      'X-API-Key': 'your-api-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ text: 'Hello%20World%21' })
  }
);
const { decoded } = await response.json();
console.log(decoded); // Hello World!

Python

import requests

response = requests.post(
    'https://api.tinyfn.io/v1/decode/url',
    headers={'X-API-Key': 'your-api-key'},
    json={'text': 'Hello%20World%21'}
)
decoded = response.json()['decoded']
print(decoded)  # Hello World!

cURL

curl -X POST "https://api.tinyfn.io/v1/decode/url" \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello%20World%21"}'

Common Use Cases

  • Query Parsing: Decode URL query parameters from incoming requests
  • Log Analysis: Decode URLs in log files for readability
  • Data Processing: Clean up URL-encoded data from databases
  • Web Scraping: Decode extracted URLs and links
  • Analytics: Decode tracking parameters for analysis

Best Practices

  1. Decode once: Don't double-decode - it can corrupt data
  2. Handle errors: Invalid sequences like %GG should be handled gracefully
  3. UTF-8 aware: Ensure proper UTF-8 handling for multi-byte characters
  4. Validate output: Sanitize decoded content before using in your app

Try the URL Decode API

Get your free API key and start decoding URLs in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key