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

language-scripts-map

v1.0.1

Published

[DEPRECATED] A reliable mapping of language codes to their default writing scripts (Latin, Cyrillic, Arabic, Devanagari, etc.).

Readme

⚠️ DEPRECATED

This package is no longer maintained.

Please use iso-639-1 instead. See: https://www.npmjs.com/package/iso-639-1


Original README below:


language-scripts-map

npm version License: MIT

TypeScript

A reliable mapping of ISO 639-1 language codes to their default writing scripts (using ISO 15924 codes like "Latn", "Cyrl", "Arab", "Deva"). This library is useful for localization engines, font selection tools, language-aware rendering, and multi-language form logic.

Features

  • 🎯 Accurate mapping of ISO 639-1 language codes to ISO 15924 script codes
  • 📦 Zero runtime dependencies
  • 🔒 TypeScript-first with strict type checking
  • 🧪 Comprehensive test coverage
  • 📚 Well-documented API
  • 🌐 Support for both ESM and CommonJS
  • 🎨 Includes script grouping (RTL/LTR)

Installation

npm install language-scripts-map

Usage

import {
  getScriptByLanguageCode,
  getLanguagesByScript,
  isValidScript,
  isScriptMatch,
  languageScriptsMap,
  SCRIPT_GROUPS,
} from 'language-scripts-map';

// Get script for a language
getScriptByLanguageCode('en'); // returns 'Latn'
getScriptByLanguageCode('ar'); // returns 'Arab'
getScriptByLanguageCode('ru'); // returns 'Cyrl'

// Get languages using a script
getLanguagesByScript('Latn'); // returns ['en', 'fr', 'de', ...]
getLanguagesByScript('Arab'); // returns ['ar', 'fa', 'ur', ...]

// Check if a script is valid
isValidScript('Latn'); // returns true
isValidScript('invalid'); // returns false

// Check if a script matches a language
isScriptMatch('en', 'Latn'); // returns true
isScriptMatch('ar', 'Arab'); // returns true
isScriptMatch('en', 'Arab'); // returns false

// Access the raw mapping data
console.log(languageScriptsMap.en); // 'Latn'
console.log(languageScriptsMap.ar); // 'Arab'

// Access script groups
console.log(SCRIPT_GROUPS.RTL); // ['Arab', 'Hebr', ...]
console.log(SCRIPT_GROUPS.LTR); // ['Latn', 'Cyrl', ...]

API Reference

Types

type ISO6391Code = string; // e.g., 'en', 'fr', 'de'
type ISO15924ScriptCode = string; // e.g., 'Latn', 'Cyrl', 'Arab', 'Deva'

interface LanguageScriptMapData {
  [languageCode: ISO6391Code]: ISO15924ScriptCode;
}

interface ScriptGroups {
  RTL: ISO15924ScriptCode[];
  LTR: ISO15924ScriptCode[];
}

Functions

getScriptByLanguageCode(languageCode: ISO6391Code | string): ISO15924ScriptCode | undefined

Gets the default script code for a given language code.

  • languageCode: ISO 639-1 language code (case-insensitive)
  • Returns: The ISO 15924 script code for the language, or undefined if not found

getLanguagesByScript(scriptCode: ISO15924ScriptCode | string): ISO6391Code[]

Gets all language codes that use a given script.

  • scriptCode: ISO 15924 script code (case-insensitive)
  • Returns: Array of ISO 639-1 language codes that use the script

isValidScript(scriptInput: string): boolean

Checks if a given script code is valid (exists in the dataset).

  • scriptInput: ISO 15924 script code to check (case-insensitive)
  • Returns: true if the script code exists in the dataset

isScriptMatch(languageCode: ISO6391Code | string, scriptInput: ISO15924ScriptCode | string): boolean

Checks if a given script is the default script for a language.

  • languageCode: ISO 639-1 language code (case-insensitive)
  • scriptInput: ISO 15924 script code to check (case-insensitive)
  • Returns: true if the script is the default for the language

Constants

languageScriptsMap: Readonly<LanguageScriptMapData>

The primary immutable object/map where keys are ISO 639-1 language codes and values are their default ISO 15924 script codes.

SCRIPT_GROUPS: Readonly<ScriptGroups>

Groups of scripts by writing direction (RTL/LTR).

Data Source

The language-to-script mapping data is sourced from the Common Locale Data Repository (CLDR) and official ISO standards. The data represents the default or most common script for each language.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.