A simple and lightweight CLI tool to convert JSON data (from files or API responses) into a human-readable Markdown table format. Perfect for documentation or quick data viewing.
- 📁 Convert a local JSON file to a Markdown table.
- 🌐 Fetch JSON data directly from an API and convert it to a table.
- 📝 Output the table to a
.md
file for easy documentation integration. - ❌ Error handling for invalid JSON input or missing parameters.
You can either install the CLI globally or run it with npx
without installation.
Run the following command to execute the tool:
npx json-to-table-cli --url <api-url> --output <output-file.md>
To install the tool globally:
npm install -g json-to-table-cli
json-to-table-cli --url https://jsonplaceholder.typicode.com/users --output users-table.md
json-to-table-cli --file ./data/users.json --output users-table.md
json-to-table-cli --help
Given the following JSON:
[
{ "id": 1, "name": "John Doe", "email": "john@example.com" },
{ "id": 2, "name": "Jane Smith", "email": "jane@example.com" }
]
The generated users-table.md
will look like this:
| ID | Name | Email |
| --- | ----------- | ----------------- |
| 1 | John Doe | john@example.com |
| 2 | Jane Smith | jane@example.com |
If something goes wrong, you'll get a clear error message. Common issues include:
- Invalid JSON format.
- Missing
--url
or--file
parameter. - File path or API endpoint not accessible.
Contributions are welcome! If you'd like to add new features or improve the code, feel free to fork the repo and submit a pull request.
This project is licensed under the MIT License.