URIError: URI malformed
decodeURIComponent/decodeURI received an invalid percent-encoded sequence.
Seen on:
JavaScript
Meaning
A stray % (like "50%off") or a truncated %E2%82 sequence makes decoding fail.
Common causes
- Literal % in data not encoded
- Double-decoding already decoded values
- Truncated UTF-8 percent sequences
⚡ Quick fix
- Encode with encodeURIComponent when building URLs
- Decode only once
- Wrap decoding in try/catch
Detailed fix by platform
JavaScript
function safeDecode(s) { try { return decodeURIComponent(s); } catch { return s; } }
How to diagnose
- Input — Which string failed?
- Encoding — Encoded/decoded how many times?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026