ToolCozy
JSON Format / DiffHOTBase64 CodecHOTURL CodecNEWTimestamp ConverterNEWUUID GeneratorHash CalculatorJWT DecoderQR Code GeneratorUnit ConverterNumber BaseData ConverterSQL FormatterIP Lookup
Image CompressHOTColor ConverterImage ConvertImage CropNEWApp Store ScreenshotNEW
Regex TesterNEWWord CounterText DiffMarkdown Preview

More Products

Playbit Games

Free online HTML5 games — play instantly in your browser

Kaola Screenshot

App Store screenshot generator with device frames & templates

Pillease

Simple pill reminder app — never miss a dose again

© 2026 ToolCozy·Privacy·Feedback

URL Codec

URL encode (encodeURIComponent) & decode

About this tool

URL encoding (also called percent-encoding) escapes characters that are reserved or unsafe in URLs — spaces, Chinese, &, =, ?, # and so on — into %XX hex sequences so a URL stays unambiguous as it travels through browsers, servers, and logs.

This tool covers three modes: encode text into a URL-safe string, decode a percent-encoded string back to its original form, and parse a full URL into its components (protocol, host, port, path, query, hash). Everything runs locally in your browser using the native encodeURIComponent / decodeURIComponent / URL APIs.

How to use

Encode / decode

  1. Pick the Encode or Decode tab.
  2. Paste your text. Output updates as you type — no button to press.
  3. Click Copy to copy the result. Errors (malformed escape sequences) are shown inline.

Parse a URL

  1. Switch to the Parse tab and paste a full URL.
  2. Each component (protocol, host, port, pathname, search, hash, and individual query params) is extracted into its own field.
  3. Copy any single field individually instead of regexing the URL by hand.

Examples

Encode a query string value

Input
name=张三&city=北京 朝阳区
Output
name%3D%E5%BC%A0%E4%B8%89%26city%3D%E5%8C%97%E4%BA%AC%20%E6%9C%9D%E9%98%B3%E5%8C%BA

Decode percent-encoded text

Input
hello%20world%21%20%F0%9F%91%8B
Output
hello world! 👋

Parse a URL

Input
https://toolcozy.com/t/url?q=base64&lang=zh#section
Output
protocol: https:
host:     toolcozy.com
pathname: /t/url
search:   ?q=base64&lang=zh
hash:     #section
params:   q=base64, lang=zh
Frequently asked questions
What's the difference between encodeURI and encodeURIComponent?

encodeURIComponent escapes everything that isn't a letter, digit, or one of - _ . ! ~ * ' ( ) — making it safe to use as a query value or path segment. encodeURI leaves URL-structural characters (: / ? # & =) alone, so it's only useful when you already have a complete URL and just want to fix unsafe characters. This tool uses encodeURIComponent.

Why is my decoded text garbled?

Almost always a character-encoding mismatch. Modern URLs use UTF-8, but some legacy systems percent-encode using GBK or other code pages. If the source wasn't UTF-8, the decoded bytes won't form valid characters — try the original system's encoding instead.

Should I encode the whole URL or just the query value?

Only encode the value. If you encode an entire URL with encodeURIComponent you'll escape the : and / and the result will no longer be a valid URL. Encode each query parameter value separately, then assemble.

What happens if a string is double-encoded?

Decode it twice. %2520 → %20 → space. Double encoding usually means a value was encoded once by client code and again by a framework or proxy. Watch for this when chaining systems.

Does Parse work on relative URLs?

No — the URL constructor needs an absolute URL with protocol. Prepend https:// if you only have a path-and-query string, or use the Decode tab to inspect the raw text instead.