A TypeScript script that generates a comprehensive CSV file containing the full hierarchy of NAICS (North American Industry Classification System) codes.
The North American Industry Classification System (NAICS) is the standard used by Federal statistical agencies in classifying business establishments for the purpose of collecting, analyzing, and publishing statistical data related to the U.S. business economy.
The script generates a CSV file in the data
directory (data/naics_full_hierarchy_with_levels.csv
) containing:
- 2-digit sector codes and titles
- 3-digit subsector codes and titles
- 4-digit industry group codes and titles
- 5-digit NAICS industry codes and titles
- 6-digit national industry codes and titles
- Node.js >= 20.0.0
- Yarn >= 1.22.0
- Clone this repository
- Install dependencies:
yarn install
Run the script to generate the NAICS hierarchy CSV:
yarn dev
The script will:
- Pull all NAICS entries (2-6 digits)
- Filter to 6-digit national industry entries
- Build the full hierarchy for each entry
- Generate a CSV file with all levels
- Save the output to
data/naics_full_hierarchy_with_levels.csv
├── src/
│ ├── index.ts # Main script
│ └── types/ # TypeScript type definitions
│ └── naics.d.ts # NAICS package type definitions
├── data/ # Output directory for generated files
├── package.json # Project configuration
└── tsconfig.json # TypeScript configuration
The project uses:
- TypeScript for type safety
- ESLint for code quality
- Prettier for code formatting
Available commands:
yarn dev
- Run the scriptyarn build
- Build TypeScriptyarn lint
- Check code qualityyarn format
- Format code
This project is private and not licensed for public use.