Created
August 13, 2025 08:15
-
-
Save gabri83/c2fd0d644e25851d73fe68ec7a8e175f to your computer and use it in GitHub Desktop.
Convert JSON to CSV (JavaScript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const json = [{ name: "Alice", age: 25 }, { name: "Bob", age: 30 }]; | |
| const csv = [ | |
| Object.keys(json[0]).join(','), | |
| ...json.map(row => Object.values(row).join(',')) | |
| ].join('\n'); | |
| console.log(csv); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment