ShieldX Toolly
Open a tool Donate
Home Home
Blog Blog
FAQ FAQ
Open a tool Donate
Back to cheatsheets
Developer

URL Encoding / Decoding

Percent-encode and decode URLs with full Unicode safety — component and full URL encoding.

2 snippets Beginner url-encoder-decoder
URL encodingpercent-encodingencodeURIComponentUnicode

What you'll learn

  • Encode / decode URL components
  • Safe URL construction

How to use these snippets

  1. Click the Copy button next to any snippet to copy it to your clipboard.
  2. Paste the code into your project, IDE, or terminal.
  3. Replace placeholder values (like example.com or your-secret) with your actual data.
  4. Review the code comments for important security notes and caveats.
  5. Try the interactive related tool to see the concept in action.
Code Snippets

Copy-paste code snippets

2 ready-to-use snippets for url encoding / decoding. Click copy and paste into your project.

Encode / decode URL components
                // Component-level encoding (most common)
const encoded = encodeURIComponent('hello world & foo=bar');
// "hello%20world%20%26%20foo%3Dbar"

const decoded = decodeURIComponent('hello%20world%20%26%20foo%3Dbar');
// "hello world & foo=bar"

// Full URL encoding (encodes fewer characters)
const urlEncoded = encodeURI(
  'https://example.com/path with spaces'
);
// "https://example.com/path%20with%20spaces"
              
Safe URL construction
                // Build URLs safely with URL API
function buildUrl(base, params) {
  const url = new URL(base);
  for (const [key, value] of Object.entries(params)) {
    url.searchParams.set(key, value);
  }
  return url.toString();
}

// Example
buildUrl('https://api.example.com/search', {
  q: 'test query',
  page: '2',
  filter: 'active&safe'
});
// "https://api.example.com/search?q=test+query&page=2&filter=active%26safe"
              
Tool

Try this concept hands-on with the interactive tool.

100% Free · No signup · No cost

Generate something unguessable right now

148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.

Open the toolkit

Part of the Toolly ecosystem · secure.toolly.site