npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

decodeuricomponent

v0.4.0

Published

A pretty fast yet robust decodeURIComponent implementation that supports unicode decoding

Readme

decodeUriComponent

A pretty fast yet robust decodeURIComponent implementation that supports unicode decoding (i.e. %uxxxx). Now also support other custom encodings such as gbk, big5, shift-jis, euc-jp, etc.

Installation

npm install decodeuricomponent

Usage

const decodeUriComponent = require('decodeuricomponent');

console.log(decodeUriComponent('2%2e8i%u624b%u52a85%u901f'));	// --> '2.8i手动5速'
console.log(decodeUriComponent('%e4%b8%ad%e5%9c%8b'));		// --> '中國'
console.log(decodeUriComponent('%b7%fe%d7%b0', 'gbk'));		// --> '服装'

Behaviour

  • A byte escape is % plus two hex digits; a unicode escape is %u plus four hex digits. Hex digits are case-insensitive.
  • A unicode escape decodes to that UTF-16 code unit (String.fromCharCode), so consecutive escapes combine into surrogate pairs: %uD83D%uDE00 -> 😀.
  • A % that does not start a valid byte or unicode escape is kept as literal text: 100% -> 100%, %zz -> %zz, a%u12 -> a%u12.
  • + is not converted to a space, and plain text passes through unchanged.
  • Without an encoding, a maximal run of byte escapes is decoded as UTF-8. Bytes that do not form a valid UTF-8 sequence (truncated, overlong, invalid lead or continuation, surrogate, above U+10FFFF) stay as their original escape text, case preserved, while valid sequences in the same run still decode: %E4%B8%AD%e4 -> 中%e4, %ff%41 -> %ffA, %c0%af -> %c0%af.
  • With an encoding, a maximal run of byte escapes is decoded by iconv.decode, so iconv-lite's replacement character applies to bytes it cannot decode.
  • Malformed input never throws in UTF-8 mode. An unknown encoding still throws iconv-lite's error.

Changes in 0.4.0

  • Malformed escapes no longer throw URIError; they are returned as literal text. This is a breaking change for callers that relied on the throw.
  • %uXXXX escapes are now decoded when an encoding is passed, not only in UTF-8 mode.

Dependency

  • Use iconv-lite to make encoding conversion;
  • Node.js 18 or later