Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 56 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# JSONormalize

[![GitHub stars](https://img.shields.io/github/stars/MrCheater/jsonormalize?style=for-the-badge&logo=github)](https://github.com/MrCheater/jsonormalize/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/MrCheater/jsonormalize?style=for-the-badge&logo=github)](https://github.com/MrCheater/jsonormalize/network)
[![GitHub issues](https://img.shields.io/github/issues/MrCheater/jsonormalize?style=for-the-badge&logo=github)](https://github.com/MrCheater/jsonormalize/issues)
[![GitHub license](https://img.shields.io/github/license/MrCheater/jsonormalize?style=for-the-badge)](https://github.com/MrCheater/jsonormalize/blob/main/LICENSE)
[![Test Coverage](https://raw.githubusercontent.com/MrCheater/jsonormalize/gh-pages/badge.svg)](https://mrcheater.github.io/jsonormalize/)
[![GitHub stars](https://img.shields.io/github/stars/analtools/jsonormalize?style=for-the-badge&logo=github)](https://github.com/analtools/jsonormalize/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/analtools/jsonormalize?style=for-the-badge&logo=github)](https://github.com/analtools/jsonormalize/network)
[![GitHub issues](https://img.shields.io/github/issues/analtools/jsonormalize?style=for-the-badge&logo=github)](https://github.com/analtools/jsonormalize/issues)
[![GitHub license](https://img.shields.io/github/license/analtools/jsonormalize?style=for-the-badge)](https://github.com/analtools/jsonormalize/blob/main/LICENSE)
[![Test Coverage](https://raw.githubusercontent.com/analtools/jsonormalize/gh-pages/badge.svg)](https://analtools.github.io/jsonormalize/)
[![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![Drizzle](https://img.shields.io/badge/Drizzle-1E88E5?style=for-the-badge&logo=drizzle&logoColor=white)](https://orm.drizzle.team/)
[![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
[![GitHub last commit](https://img.shields.io/github/last-commit/MrCheater/jsonormalize?style=for-the-badge&logo=git)](https://github.com/MrCheater/jsonormalize/commits/main)
[![GitHub repo size](https://img.shields.io/github/repo-size/MrCheater/jsonormalize?style=for-the-badge&logo=github)](https://github.com/MrCheater/jsonormalize)
[![GitHub last commit](https://img.shields.io/github/last-commit/analtools/jsonormalize?style=for-the-badge&logo=git)](https://github.com/analtools/jsonormalize/commits/main)
[![GitHub repo size](https://img.shields.io/github/repo-size/analtools/jsonormalize?style=for-the-badge&logo=github)](https://github.com/analtools/jsonormalize)

## 🚀 Description

Expand Down Expand Up @@ -41,11 +41,11 @@ Currently supports **SQLite** with plans to expand to PostgreSQL, MySQL, and oth

Check out the examples/ directory for ready-to-use JSON samples:

- [`examples/simple/`](https://github.com/MrCheater/jsonormalize/tree/main/examples/simple/) - Basic data structures
- [`examples/simple/`](https://github.com/analtools/jsonormalize/tree/main/examples/simple/) - Basic data structures

- [`examples/complex/`](https://github.com/MrCheater/jsonormalize/tree/main/examples/complex/) - Real-world scenarios
- [`examples/complex/`](https://github.com/analtools/jsonormalize/tree/main/examples/complex/) - Real-world scenarios

- [`examples/edge-cases/`](https://github.com/MrCheater/jsonormalize/tree/main/examples/edge-cases/) - Special data patterns
- [`examples/edge-cases/`](https://github.com/analtools/jsonormalize/tree/main/examples/edge-cases/) - Special data patterns

## 📦 Installation

Expand All @@ -63,7 +63,7 @@ pnpm add jsonormalize

````bash
```sh
curl -o example.json https://raw.githubusercontent.com/MrCheater/jsonormalize/main/examples/simple/users.json
curl -o example.json https://raw.githubusercontent.com/analtools/jsonormalize/main/examples/simple/users.json
````

### Generate SQLite migration
Expand All @@ -75,7 +75,7 @@ npx jsonormalize sqlite:setup ./example.json ./demo.sqlite3
### Or directly from URL (requires fetch support in your CLI)

```sh
npx jsonormalize sqlite:setup https://raw.githubusercontent.com/MrCheater/jsonormalize/main/examples/simple/users.json ./demo.db
npx jsonormalize sqlite:setup https://raw.githubusercontent.com/analtools/jsonormalize/main/examples/simple/users.json ./demo.db
```

### Using local JSON file
Expand All @@ -86,17 +86,57 @@ npx jsonormalize sqlite:setup ./data.json ./app.sqlite3

## ❓ Help

### CLI

```
Usage: jsonormalize [options] [command]

JSONormalize — Transform any JSON into a relational database schema. Automatically normalizes nested structures, detects relationships, and generates SQLite
migrations. Perfect for rapid prototyping, data migrations, and structured data workflows.

Options:
-h, --help display help for command
-h, --help display help for command

Commands:
sqlite:setup <json-path> <db-path> 🗄️ Setup tables, indexes and seed with data from JSON
sqlite:sql <json-path> <sql-path> 🛠️ Generate SQL for create tables, indexes and seed with data from JSON
help [command] display help for command
postgres:setup [options] <json-path> [db-path] 🗄️ Setup tables, indexes and seed with data from JSON
postgres:sql <json-path> <sql-path> 🛠️ Generate SQL for create tables, indexes and seed with data from JSON
sqlite:setup <json-path> [db-path] 🗄️ Setup tables, indexes and seed with data from JSON
sqlite:sql <json-path> <sql-path> 🛠️ Generate SQL for create tables, indexes and seed with data from JSON
help [command] display help for command
```

### Command "jsonormalize postgres:setup"

```
Usage: jsonormalize postgres:setup [options] <json-path> [db-path]

🗄️ Setup tables, indexes and seed with data from JSON

Arguments:
json-path Path to JSON file with any data (table structure will be inferred)
db-path Path to the database file or ':memory:' (no file, RAM only)

Options:
--user <user> default process.env.PGUSER || process.env.USER
--password <password> default process.env.PGPASSWORD
--host <host> default process.env.PGHOST
--port <port> default process.env.PGPORT
--database <database> default process.env.PGDATABASE || user
--connection-string <connectionString> e.g. postgres://user:password@host:5432/database
--ssl <ssl> passed directly to node.TLSSocket, supports all tls.connect options
--statement-timeout <statementTimeout> number of milliseconds before a statement in query will time out, default is no
timeout
--query-timeout <queryTimeout> number of milliseconds before a query call will timeout, default is no timeout
--lock-timeout <lockTimeout> number of milliseconds a query is allowed to be en lock state before it's cancelled
due to lock timeout
--application-name <applicationName> The name of the application that created this Client instance
--connection-timeout-millis <connectionTimeoutMillis> number of milliseconds to wait for connection, default is no timeout
--keep-alive-initial-delay-millis <keepAliveInitialDelayMillis> set the initial delay before the first keepalive probe is sent on an idle socket
--idle-in-transaction-session-timeout <idleInTransactionSessionTimeout> number of milliseconds before terminating any session with an open idle transaction,
default is no timeout
--client-encoding <clientEncoding> specifies the character set encoding that the database uses for sending data to the
client
--fallback-application-name <fallbackApplicationName> provide an application name to use if application_name is not set
--options <options> command-line options to be sent to the server
-h, --help display help for command
```
175 changes: 171 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@analtools/jsonormalize",
"version": "0.0.4",
"version": "0.0.6",
"description": "JSONormalize — Transform any JSON into a relational database schema. Automatically normalizes nested structures, detects relationships, and generates SQLite migrations. Perfect for rapid prototyping, data migrations, and structured data workflows.",
"keywords": [
"json-normalize",
Expand Down Expand Up @@ -44,7 +44,7 @@
},
"homepage": "https://github.com/analtools/jsonormalize#readme",
"bin": {
"json-to-drizzle": "./bin/run.js"
"jsonormalize": "./bin/run.js"
},
"main": "dist/src/index.js",
"type": "commonjs",
Expand All @@ -55,6 +55,7 @@
"@types/better-sqlite3": "^7.6.13",
"@types/node": "^24.1.0",
"@types/node-fetch": "^2.6.13",
"@types/pg": "^8.16.0",
"@vitest/coverage-v8": "^4.0.16",
"coverage-badges-cli": "^2.2.0",
"eslint": "^9.39.2",
Expand All @@ -70,6 +71,8 @@
},
"dependencies": {
"better-sqlite3": "^12.5.0",
"@electric-sql/pglite": "^0.3.14",
"pg": "^8.16.3",
"commander": "^14.0.2",
"node-fetch": "2.7.0"
},
Expand Down
Loading