{"id":14483418,"url":"https://github.com/kindly/flatterer","last_synced_at":"2026-01-18T12:40:05.223Z","repository":{"id":43199545,"uuid":"385549156","full_name":"kindly/flatterer","owner":"kindly","description":"Opinionated JSON to CSV/XLSX/SQLITE/PARQUET converter.  Flattens JSON fast.","archived":false,"fork":false,"pushed_at":"2025-06-26T07:40:05.000Z","size":9645,"stargazers_count":198,"open_issues_count":5,"forks_count":7,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-08-30T04:36:06.678Z","etag":null,"topics":["csv","flatten","json","python","rust"],"latest_commit_sha":null,"homepage":"https://docs.flatterer.dev","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kindly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-13T09:29:31.000Z","updated_at":"2025-08-03T20:28:19.000Z","dependencies_parsed_at":"2024-01-17T08:45:06.826Z","dependency_job_id":"4857b789-599a-494d-95a0-e8b19b074388","html_url":"https://github.com/kindly/flatterer","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/kindly/flatterer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindly%2Fflatterer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindly%2Fflatterer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindly%2Fflatterer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindly%2Fflatterer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kindly","download_url":"https://codeload.github.com/kindly/flatterer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindly%2Fflatterer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28536003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","flatten","json","python","rust"],"created_at":"2024-09-03T00:01:44.856Z","updated_at":"2026-01-18T12:40:05.165Z","avatar_url":"https://github.com/kindly.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003cimg width=\"500\" src=\"./docs/_static/flatterer-with-text.svg\"\u003e\n\n[Full Documentation](http://docs.flatterer.dev/)\n\n## Introduction\n\nAn opinionated JSON to CSV/XLSX/SQLITE/PARQUET converter which tries to make a useful relational output for data analysis.\n\n[Web playgroud of CSV/XLSX conversions](https://lite.flatterer.dev/)\n\n## Rationale\n\nWhen receiving a JSON file where the structure is deeply nested or not well specified, it is hard to determine what the data contains. Also, even after knowing the JSON structure, it requires a lot of time to work out how to flatten the JSON into a relational structure to do data analysis on and to be part of a data pipeline. \n\nFlatterer aims to be the first tool to go to when faced with the above problem.  It may not be the tool that you end up using to flatten the JSON in your data pipeline, as hand written flattening may be required, but it could be.  It has many benefits over most hand written approaches:\n\n* It is fast, written in rust but with python bindings for ease of use.  It can be 10x faster than hand written python flattening.\n* Memory efficient.  Uses a custom streaming JSON parser to mean that long list of objects nested with the JSON will be streamed, so not much data needs to be loaded into memory at once.\n* Fast memory efficient output to CSV/XLSX/SQLITE/PARQUET\n* Uses best practice that has been learnt from flattening JSON countless times, such as generating keys to link one-to-many tables to their parents.\n\n### Install\n\n```bash\npip install flatterer\n```\n\nFlatterer requires Python 3.6 or greater. It is written as a python extension in Rust but has binaries (wheels) for linux (x64), macos (x64 and universal) and windows (x64, x86).  On other platforms a rust toolchain will need to be installed.\n\n### Example JSON\n\nSay you have a JSON data like this named `games.json`:\n\n```json\n[\n  {\n    \"id\": 1,\n    \"title\": \"A Game\",\n    \"releaseDate\": \"2015-01-01\",\n    \"platforms\": [\n      {\"name\":\"Xbox\"},\n      {\"name\":\"Playstation\"}\n    ],\n    \"rating\": {\n      \"code\": \"E\",\n      \"name\": \"Everyone\"\n    }\n  },\n  {\n    \"id\": 2,\n    \"title\": \"B Game\",\n    \"releaseDate\": \"2016-01-01\",\n    \"platforms\": [\n      {\"name\":\"PC\"}\n    ],\n    \"rating\": {\n      \"code\": \"E\",\n      \"name\": \"Everyone\"\n    }\n  }\n]\n```\n\n\n### Running Flatterer\n\nRun the above file with flatterer.\n\n```bash\nflatterer games.json games_dir\n```\n\n### Output Files\n\n\nBy running the above you will get the following files:\n\n```bash\ntree games_dir\n\ngames_dir/\n├── csv\n│   ├── games.csv\n│   └── platforms.csv\n├── datapackage.json\n├── fields.csv\n└── ...\n```\n\n#### Main Table\n\n`games.csv` contains:\n\n|_link|_link_games|id |rating_code|rating_name|releaseDate|title |\n|-----|---------- |---|-----------|-----------|-----------|------|\n|1    |1          |1  |E          |Everyone   |2015-01-01 |A Game|\n|2    |2          |2  |E          |Everyone   |2016-01-01 |B Game|\n\n\nSpecial column `_link` is generated. `_link` is the primary key there unique per game. \n\nAlso the `rating` sub-object is promoted to this table it has a one-to-one relationship with `games`. \nSub-object properties are separated by '_'.  \n\n#### One To Many Table\n\n`platforms` is an array so is a one-to-many with games therefore needs its own table: \n`platforms.csv` contains:\n\n|_link|_link_games|name|\n|-----|----------|----|\n|1.platforms.0|1 |Xbox|\n|1.platforms.1|1 |Playstation|\n|2.platforms.0|2 |PC  |\n\n#### Link Fields\n\n`_link` is the primary key for the `platforms` table too.  Every table except `games` table, contains a `_link_games` field to easily join to the main `games` table.\n\nIf there was a sub-array of `platforms` then that would have `_link`,  `_link_games` and  `_link_platforms` fields. \n\nTo generalize this the `_link__\u003ctable_name\u003e` fields joins to the `_link` field of `\u003ctable_name\u003e` i.e the `_link__\u003ctable_name\u003e` are the foreign keys refrencing `\u003ctable_name\u003e._link`.\n\n#### Fields CSV\n\n`fields.csv` contains some metadata about the output tables:\n\n|table_name |field_name|field_type|count|field_title|\n|-----------|----------|----------|-----|----------|\n|platforms  |_link     |text      |3    |_link     |\n|platforms  |_link_games|text     |3    |_link_games|\n|platforms  |name      |text      |3    |name      |\n|games      |_link     |text     |2    | _link     |\n|games      |id        |number   |2    | id        |\n|games      |rating_code|text    |2    | rating_code|\n|games      |rating_name|text    |2    | rating_name|\n|games      |releaseDate|date    |2    | releaseDate|\n|games      |title     |text     |2    | title     |\n\nThe `field_type` column contains a type guess useful for inserting into a database. The `field_title` is the column heading in the CSV file or XLSX tab, which is initally the same as the field_name.\nAfter editing this file then you can rerun the transform:\n\n\n```bash\nflatterer games.json new_games_dir -f myfields.csv --only-fields\n```\n\nThis can be useful for renameing columns, rearranging the field order or if you want to remove some fields the `--only-fields` flag will only include the fields in the edited file.\n\n`datapackage.json` contains metadata in the [Tabular Data Package Spec](https://specs.frictionlessdata.io/tabular-data-package/#language)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkindly%2Fflatterer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkindly%2Fflatterer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkindly%2Fflatterer/lists"}