Fix Malformed Percent-Encoding

See why decodeURIComponent throws on a trailing % or a lone %2, and how to clean the string before decoding.

Part of the free URL Decoder. Runs in your browser — nothing is uploaded.

Fix Malformed Percent-Encoding

JavaScript throws URIError: URI malformed when a % is not followed by two hex digits. That usually means a truncated log line, a copy-paste cut-off, or a literal percent that was never encoded as %25.

Worked example: A truncated value

Encoded

hello%2

Error

URIError: URI malformed
%2 is not a complete %HH pair

Practical tip

Replace leftover % that are not %HH with %25, then decode. Or reject the input — a truncated token should not be trusted.

How to use this URL Decoder

  1. 1Use the live tool above — it runs entirely in your browser and never uploads your data.
  2. 2Paste the sample from the worked example, or use your own input.
  3. 3Copy the result, then adapt the same steps in your editor, script, or pipeline.

Fix Malformed Percent-Encoding FAQs

Why does decodeURIComponent throw?

A % is missing its two hex digits, or the resulting bytes are not valid UTF-8.

How do I decode safely in JavaScript?

try { decodeURIComponent(s) } catch { return s } — or show the error so the caller can fix the value.