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

excel-to-sql-converter

v1.0.0

Published

A TypeScript library to convert Excel/CSV/JSON files to SQL INSERT statements

Downloads

3

Readme

Excel to SQL Converter

A TypeScript library for converting Excel, CSV, and JSON files to SQL INSERT statements.

Features

  • Convert Excel (.xlsx, .xls), CSV, and JSON files to SQL INSERT statements
  • Automatic type inference for columns
  • Customizable table names and column types
  • Support for various SQL data types (VARCHAR, INT, DECIMAL, DATE, DATETIME, etc.)
  • Command-line interface (CLI) and programmatic API
  • Built with TypeScript for type safety

Installation

npm install excel-to-sql-converter
# or
yarn add excel-to-sql-converter

Usage

Basic Usage

import { ExcelToSqlConverter } from 'excel-to-sql-converter';

// Convert an Excel file to SQL
async function convertExcelToSql() {
  const result = await ExcelToSqlConverter.convertFile('input.xlsx', {
    tableName: 'my_table',
    outputDir: './output'
  });
  
  console.log(`Generated SQL for ${result.rowCount} rows`);
  console.log(`SQL saved to: ${result.outputFile}`);
}

// Convert JSON data to SQL
function convertJsonToSql() {
  const data = [
    { id: 1, name: 'John Doe', age: 30 },
    { id: 2, name: 'Jane Smith', age: 25 }
  ];
  
  const result = ExcelToSqlConverter.convertJson(data, {
    tableName: 'users',
    columnTypes: {
      id: 'number',
      name: 'string',
      age: 'number'
    }
  });
  
  console.log(result.sql);
}

Command Line Interface

# Convert an Excel file to SQL
npx excel-to-sql input.xlsx -t my_table -o ./output

# Convert a CSV file to SQL
npx excel-to-sql data.csv -t my_table --format csv -o ./output

# Show help
npx excel-to-sql --help

API Reference

ExcelToSqlConverter.convertFile(filePath: string, options?: ConvertOptions): Promise<ConversionResult>

Converts a file to SQL statements.

Parameters:

  • filePath: Path to the input file (Excel, CSV, or JSON)
  • options: Optional configuration (see below)

Returns: A promise that resolves to a ConversionResult object

ExcelToSqlConverter.convertJson(data: Record<string, any>[], options?: ConvertOptions): ConversionResult

Converts an array of objects to SQL statements.

Parameters:

  • data: Array of objects to convert
  • options: Optional configuration (see below)

Returns: A ConversionResult object

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | tableName | string | Derived from filename | Name of the SQL table | | headerRow | number | 0 | Row index (0-based) containing headers | | sheetName | string | First sheet | Name of the sheet to convert (Excel only) | | outputDir | string | undefined | Directory to save the SQL file | | columnTypes | Record<string, ColumnType> | Inferred | Column type overrides | | skipHeader | boolean | false | Skip the header row in the output |

ConversionResult

| Property | Type | Description | |----------|------|-------------| | sql | string | Generated SQL statements | | tableName | string | Name of the SQL table | | rowCount | number | Number of rows converted | | outputFile | string | Path to the output file (if outputDir was specified) |

License

MIT