Blog
Custom Print on Demand Apparel — Free Storefront for Your Business
Wild & Free Tools

Convert CSV to JSON on Mac, Linux, and Windows — Native Commands + Browser

Last updated: April 20268 min readConverter Tools

Every major operating system can convert CSV to JSON natively — Mac and Linux with Python, Windows with PowerShell. Here are the exact commands for each platform, plus the cross-platform browser option that skips the terminal entirely.

Mac / Linux: Python One-Liner

macOS ships with Python 3. Most Linux distributions (Ubuntu, Fedora, Debian, Arch) include it too. Open your terminal and run:

python3 -c "import csv,json,sys; print(json.dumps(list(csv.DictReader(open(sys.argv[1], encoding='utf-8-sig'))), indent=2))" data.csv

This prints formatted JSON directly to your terminal. To save it as a file:

python3 -c "import csv,json,sys; print(json.dumps(list(csv.DictReader(open(sys.argv[1], encoding='utf-8-sig'))), indent=2))" data.csv > output.json

What is happening in that one-liner:

Windows: PowerShell (Zero Install)

PowerShell ships with every Windows 10 and 11 installation. No Python, no npm, no downloads needed:

Import-Csv data.csv | ConvertTo-Json | Out-File output.json

That is the entire command. PowerShell reads the CSV, converts each row to a PowerShell object, serializes to JSON, and writes the file.

For large files, add depth control and encoding:

Import-Csv data.csv -Encoding UTF8 | ConvertTo-Json -Depth 10 | Out-File output.json -Encoding UTF8

PowerShell gotcha: By default, ConvertTo-Json has a depth limit of 2. If your data is simple (flat CSV), this does not matter. If you are processing complex data, set -Depth 10 to avoid truncation.

All Platforms: Browser Tool (No Terminal, No Install)

If you do not want to open a terminal at all:

  1. Open the CSV to JSON Converter in any browser
  2. Paste your CSV (or open your .csv file in a text editor, select all, copy, paste)
  3. Copy the JSON output
  4. Paste into your target application or save as a .json file

Works on Mac, Windows, Linux, ChromeOS, tablets, and phones. No Python version issues, no PATH configuration, no terminal familiarity required.

Platform Comparison

CriteriaMac/Linux PythonWindows PowerShellBrowser Tool
Pre-installed?✓ Yes (Mac + most Linux)✓ Yes (Win 10/11)✓ Just needs a browser
Speed for small files✓ Instant✓ Instant✓ Instant
Speed for large files✓ Handles millions of rows~Slower on 100K+ rows~Slows at 50K+ rows
Encoding handling✓ utf-8-sig for BOM✓ -Encoding UTF8✓ Automatic
Scriptable / automatable✓ Cron, bash scripts✓ Task Scheduler✗ Manual process
Learning curve~Need terminal basics~Need PowerShell basics✓ None — paste and copy
Custom delimiters✓ delimiter parameter✓ -Delimiter parameter✓ Dropdown or auto-detect
Data stays local✓ Yes✓ Yes✓ Yes (no upload)

Advanced: Making It a Reusable Command

Mac/Linux — add to your shell profile:

# Add to ~/.bashrc or ~/.zshrc
csv2json() { python3 -c "import csv,json,sys; print(json.dumps(list(csv.DictReader(open(sys.argv[1], encoding='utf-8-sig'))), indent=2))" "$1"; }

Then convert any file with: csv2json data.csv > output.json

Windows — create a PowerShell function:

# Add to your PowerShell profile
function csv2json { param($f) Import-Csv $f -Encoding UTF8 | ConvertTo-Json -Depth 10 }

Then: csv2json data.csv | Out-File output.json

Platform-Specific Gotchas

PlatformGotchaFix
Macpython vs python3 — macOS may have Python 2 as defaultAlways use python3 explicitly
Ubuntu 24+Python may not be pre-installed on minimal installssudo apt install python3
WindowsPowerShell execution policy may block scriptsRun Set-ExecutionPolicy RemoteSigned in admin terminal
WindowsConvertTo-Json wraps single-row CSV in object, not arrayPipe through @() to force array: @(Import-Csv file) | ConvertTo-Json
AllCSV from Excel has invisible BOM bytesPython: utf-8-sig encoding. PowerShell: -Encoding UTF8.
AllEuropean CSV uses semicolons, not commasPython: delimiter=";" — PowerShell: -Delimiter ";"

Complete Data Toolkit

Works on Mac, Windows, Linux — paste CSV, get JSON, no install needed.

Open CSV to JSON Converter
Launch Your Own Clothing Brand — No Inventory, No Risk