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

@omni-stove/csv-i18n

v2025.7.1

Published

Converts CSV files in a directory to a single JSON file for i18n.

Downloads

53

Readme

CSV to i18n TypeScript Converter (csv-i18n)

A command-line tool to recursively find CSV files in a specified directory, parse them, and generate TypeScript files (one per language) containing flat key-value pairs suitable for internationalization (i18n).

Installation

# Install globally (if needed)
npm install -g .

# Or run directly using npx
# npx . --input <input-dir> --output <output-file>

(Note: For publishing to npm or GitHub Packages, you'd typically install by package name after publishing.)

Usage

csv-i18n --input <path/to/csv/directory> --output <path/to/output/directory>

Or using npx:

npx . --input <path/to/csv/directory> --output <path/to/output/directory>

Options

  • -i, --input <dir>: (Required) The input directory containing the CSV files. The tool will search this directory recursively.
  • -o, --output <dir>: (Required) The path to the output directory where the generated files (e.g., ja.ts, en.ts or ja.json, en.json) should be saved. The directory will be created if it doesn't exist.
  • -f, --format <type>: (Optional) The output format type. Can be typescript (default) or i18next (generates nested JSON).
  • -w, --watch: (Optional) Watch the input directory for changes and automatically re-run the conversion. Press Ctrl+C to stop watching. 33 |

CSV Format

  • Files must have a .csv extension.
  • Files must be UTF-8 encoded.
  • The first row must be a header row.
  • There must be a column named key (case-insensitive check, but prefer lowercase key). This column contains the final part of the translation key.
  • All other columns are treated as language codes (e.g., ja, en, fr). The values in these columns are the translations for that language.
  • Empty cells or cells with only whitespace will be ignored for that specific language key.
  • Rows without a valid key will be skipped with a warning.

TypeScript Output Structure

The tool generates the following files in the specified output directory:

  1. Language Files (<lang>.ts): One TypeScript file per detected language (e.g., ja.ts, en.ts). Each file exports a default object containing flat key-value pairs for that language. The keys are constructed by combining the relative path of the CSV file (from the input directory, using dots as separators) and the key value from the CSV.
  2. Key File (key.ts): A single TypeScript file that exports a default object containing all unique translation keys found across all CSV files. Both the keys and values in this object are the translation key strings (e.g., { "common.greeting": "common.greeting", ... }). This can be useful for type safety or referencing keys in code.

Example:

If the input directory is locales/csv and contains:

  • locales/csv/common.csv:
    key,ja,en
    greeting,こんにちは,Hello
  • locales/csv/components/button.csv:
    key,ja,en
    submit,送信,Submit
    cancel,キャンセル,Cancel

Running csv-i18n --input locales/csv --output dist/ts would produce the following files in the dist/ts directory:

  • dist/ts/ja.ts:
    // Auto-generated by csv-i18n tool. Do not edit manually.
    export default {
      "common.greeting": "こんにちは",
      "common.farewell": "さようなら",
      "components.button.submit": "送信",
      "components.button.cancel": "キャンセル"
    };
  • dist/ts/en.ts:
    // Auto-generated by csv-i18n tool. Do not edit manually.
    export default {
      "common.greeting": "Hello",
      "common.farewell": "Goodbye",
      "components.button.submit": "Submit",
      "components.button.cancel": "Cancel"
    };
  • (And potentially fr.ts if the fr column exists in the CSVs)
  • dist/ts/key.ts:
    // Auto-generated by csv-i18n tool. Do not edit manually.
    export default {
      "common.farewell": "common.farewell",
      "common.greeting": "common.greeting",
      "components.button.cancel": "components.button.cancel",
      "components.button.submit": "components.button.submit"
    };

Development

  1. Clone the repository.
  2. Run npm install.
  3. You can run the tool directly using node src/index.js --input ... --output ....