Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

idna-uts46-hx

Convert Domain Names correctly from IDN to Punycode and vice-versa and offer TR46 processing.

unicode, idn, idna, domain, convert, converter

readme

IDNA-UTS #46 in JavaScript

npm version node semantic-release License: MIT PRs welcome

This module is a IDNA UTS46 connector library for javascript. In addition to the default functionality of tr46, we offer converting domain names to unicode / punycode considering the respective registry provider's behavior.

The JS Punycode converter library is a great tool for handling Unicode domain names, but it only implements the Punycode encoding of domain labels, not the full IDNA algorithm. In simple cases, a mere conversion to lowercase text before input would seem sufficient, but the real mapping for strings is far more complex. This library implements the full mapping for these strings, as defined by UTS #46.

Resources

v6 Notes & Migration Guide

With v6 we migrated our library to npm package tr46 as software dependency. By that step we use a library that is actively maintained in direction of correctly supporting the TR46 standard and supporting the latest Version of the Unicode Standard. Reinventing the wheel isn't useful and something we have time or resources for. We were able to dramatically decrease the number of lines of code on our end.

Improvements

  • method toUnicode comes with auto-detection of transitionalProcessing setting based on the provided domain name input
  • method toAscii comes with auto-detection of transitionalProcessing setting based on the provided domain name input

Breaking Changes

In general, we don't see a blocker for upgrading to v6. Still, consider the below changes.

Performance

Runtime performance of v6 compared to v5 has slightly improved. The compression for the underlying idna mapping table is superfluous, tr46 covers it well.

New Labels for Options

The below configuration options for the methods toUnicodeand toAscii must be renamed in case you're using them:

Option, old Option, new
transitional transitionalProcessing
useStd3ASCII useSTD3ASCIIRules
verifyDnsLength verifyDNSLength

Behavior

Earlier versions kept option transitional by default to false which is now automatically detected and results may therefore differ. This affects the toAscii method.

The toUnicode function did not allow for a options parameter in earlier versions, now it follows the exemplary way of package tr46.

Authors

Thanks for the below former contributions:

  • Initial work done by jcranmer.
  • v5: Migration of the IDNA Mapping Table's Build Process from Python to NodeJS5 by dawsbot
  • v5: Performance Improvements for the Browser Bundle's Page Load by dawsbot

See also the list of contributors who participated in this project.

License

MIT

changelog

6.0.8 (2025-04-17)

Bug Fixes

  • deps: bump tr46 from 5.1.0 to 5.1.1 (86a7876)

6.0.7 (2025-03-17)

Bug Fixes

  • deps: bump tr46 from 5.0.0 to 5.1.0 (2e4c02a)

6.0.6 (2024-11-19)

Bug Fixes

  • deps: bump cross-spawn from 7.0.3 to 7.0.5 (e1c0581)

6.0.5 (2024-07-25)

Performance Improvements

  • index.php: extend transitional TLDs array with '.art' TLD (759e00d)

6.0.4 (2024-04-10)

Bug Fixes

6.0.3 (2024-3-1)

Bug Fixes

  • readme: reflect changes related to performance to the public (30d3f45)

6.0.2 (2024-2-23)

Bug Fixes

  • readme: review note about performance (e38a99c)

6.0.1 (2024-2-23)

Bug Fixes

  • build: add missing type definitions (4a152c8)

6.0.0 (2024-2-22)

Code Refactoring

  • tr46: reviewed in direction of tr46 as core library and adding our logic around (d0c080a)

BREAKING CHANGES

  • tr46: Migration to package tr46. Find Notes and Migration Guide as part of the README.md

5.1.2 (2023-10-31)

Bug Fixes

  • deps: bump punycode from 2.3.0 to 2.3.1 (1e4d79a)

5.1.1 (2023-10-20)

Bug Fixes

  • punycode: ensure to use the user-land replacement (6c3a3c2)

5.1.0 (2023-09-18)

Features

  • unicode: upgraded version (cb662c3)

5.0.7 (2023-03-13)

Performance Improvements

  • build: improve build size again (1kb) (8b12436)

5.0.6 (2023-03-13)

Performance Improvements

  • build: minor improvement to file sizes of dist files (19e61da)

5.0.5 (2023-03-10)

Bug Fixes

  • esm: switched to type module while CJS + Bundle can still be directly accessed via dist folder (c3e1064)

5.0.4 (2023-03-09)

Bug Fixes

  • package.json: fix path to main file (77561b7)

5.0.3 (2023-03-09)

Bug Fixes

  • rollup: merged config files (05c22d8)

5.0.2 (2023-03-09)

Bug Fixes

  • build: add missing devDependencies (b3f692a)
  • build: added missing semantic-release configuration file and typings file (bd3f43a)
  • dist: some minor review and cleanup of typings (3fdff33)

4.1.2 (2022-12-09)

Bug Fixes

  • unicode v15.0.0: regenerated .js files (idna-map files were empty) (cb00f51)

4.1.1 (2022-12-09)

Bug Fixes

  • code style: prettier-ified (e919514)

4.1.0 (2022-12-09)

Features

4.0.4 (2022-09-14)

Bug Fixes

  • punycode: don't use the punycode module shipped with nodejs, read #148 (78bfc91)

4.0.3 (2022-07-04)

Performance Improvements

  • downsizing idna-map: moving Uint32Array to const var for reuse and thus downsizing entire file (da056b9)

4.0.2 (2022-06-08)

Bug Fixes

  • dep bump: upgraded "engines" and dev deps (1961f78)

4.0.1 (2022-06-08)

Bug Fixes

  • github workflows: fixed to always rely on latest node version number (nodejs/npm vuln) (4e01d90)

4.0.0 (2022-05-02)

Bug Fixes

  • dep-bump: added pkg "future" to requirements.txt until python2 support got totally cleaned up (6610158)
  • pep8: fixed addressed issues (f6e4acc)

chore

  • python3: support added for generator script (build-unicode-tables.py) (ead43c0)

BREAKING CHANGES

  • python3: Module generated using the python3 ported generator script.

3.5.0 (2022-05-02)

Features

  • unicode 14.0.0: upgraded, enjoy! (4fec362)

3.4.1 (2022-04-29)

Performance Improvements

  • bundled version: minify idna-map.js and rely on it as well (0b0ffc9)

3.4.0 (2021-03-22)

Features

  • unicode: update to v13.0.0 (2741d21)

3.3.1 (2021-01-26)

Bug Fixes

  • ci: migration from Travis CI to github actions (ebadb75)
  • ci: remove --user flag for pip install (8749327)

Reverts

  • travis: reverting change of travis-ci config (8e804da)

3.3.0 (2020-05-18)

Features

  • typescript: adding type definitions (8d0231f)

3.2.2 (2019-09-18)

Bug Fixes

  • release process: review git-plugin usage; dep-bump cross-env; (0ec058a)

3.2.1 (2019-09-18)

Bug Fixes

  • release process: reuse @hexonet/semantic-release-github-npm-config (46a3abb)

3.2.0 (2019-05-16)

Features

  • unicode: upgrade to v12.1.0 (ee5877b)

3.1.1 (2019-05-13)

Bug Fixes

3.1.0 (2019-05-13)

Bug Fixes

  • dep-add: missing @semantic-release/exec in dev-deps (35eb502)

Features

  • uts46: add convert method for automatic conversion of domain names (84fcbe2)

3.0.0 (2019-04-15)

Documentation

Bug Fixes

  • pep8: fix pep8 format check script (464ffd4)
  • travis: fix build steps (3f60010)
  • travis: install python requirements in user space (bda853a)
  • travis: review build step requirements and docs (f890546)

BREAKING CHANGES

  • readme: just bumping major release as of CI/CD review in direction of Travis CI and semantic-release.

Features

  • pkg: upgrade to unicode 12.0.0; introduce travis ci (ecfc57f)

OLDER RELEASES (manually documented)

2017-11-06 / 2.3.0 - 2.3.1

  • replaced for .. of loop in uts46.js on Line 111 with simple for loop. I don't expect this to break as no codepoint logic has to be payed heed to.

2017-04-18

  • Switched automated tests to fit our own way
    • dropped out grunt
    • introduced nyc
    • introduced mocha.opts
    • npm test now runs both: tests and coverage report
    • add .nyc_output to gitignore
    • renamed test source code files to .spec.js as this is very common
  • re-validated source codes, still open: idna-map.js
  • updated .jshintrc config
  • added IDN translation cases found on unicode.org (see test-uts46.spec.js). Need to investigate further

2017-04-10

Initial Fork Release covering:

  • dependenncy upgrades
    • chai 3.5.0
    • grunt 0.4.5 -> 1.0.1
    • grunt-mocha-istanbul 3.0.1 -> 5.0.2
    • grunt-mocha-test 0.12.7 -> 0.13.2
    • istanbul 0.3.22 -> 0.4.5
    • mocha 2.5.3 -> 3.2.0
    • punycode 1.4.1 -> 2.1.0
  • Added HISTORY.md (Changelog)
  • Upgraded IDNA Map to unicode 9.0.0
  • Updated README.md to cover: build-unicode-tables.py
  • Add test/IdnaTest.txt to gitignore as it get autogenerated
  • Re-validated test source scripts