⚙️ Settings
WITH recent_orders AS (
SELECT
customer_id,
order_id,
order_date,
total_amount
FROM orders
WHERE order_date >= DATEADD(day, -30, GETDATE())
)
SELECT
customer_id,
COUNT(order_id) AS order_count,
SUM(total_amount) AS total_spent
FROM recent_orders
GROUP BY customer_id
ORDER BY total_spent DESC;
WITH RECURSIVE employee_hierarchy AS (
-- Anchor: top-level rows (no manager)
SELECT
employee_id,
manager_id,
employee_name,
1 AS level
FROM employees
WHERE manager_id IS NULL
UNION ALL
-- Recursive: join children to their parent's result
SELECT
e.employee_id,
e.manager_id,
e.employee_name,
eh.level + 1
FROM employees e
INNER JOIN employee_hierarchy eh
ON e.manager_id = eh.employee_id
)
SELECT *
FROM employee_hierarchy
ORDER BY level, employee_name;
-- Note: SQL Server / Oracle: drop the RECURSIVE keyword (just WITH employee_hierarchy AS (...))
SELECT
o.order_id,
c.customer_name,
o.order_date,
p.product_name,
oi.quantity
FROM orders o
INNER JOIN customers c
ON o.customer_id = c.customer_id
LEFT JOIN order_items oi
ON o.order_id = oi.order_id
LEFT JOIN products p
ON oi.product_id = p.product_id
WHERE o.order_date >= '2026-01-01'
ORDER BY o.order_date DESC;
SELECT
DATE_TRUNC('month', order_date) AS order_month, -- PostgreSQL
-- FORMAT(order_date, 'yyyy-MM') AS order_month, -- SQL Server
-- DATE_FORMAT(order_date, '%Y-%m') AS order_month, -- MySQL
COUNT(*) AS order_count,
SUM(total_amount) AS revenue
FROM orders
GROUP BY DATE_TRUNC('month', order_date)
ORDER BY order_month;
SELECT
customer_id,
order_id,
order_date,
total_amount,
ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY order_date DESC
) AS order_rank,
SUM(total_amount) OVER (
PARTITION BY customer_id
ORDER BY order_date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS running_total
FROM orders;
CREATE PROCEDURE GetCustomerOrders
@CustomerId INT,
@StartDate DATE = NULL,
@EndDate DATE = NULL
AS
BEGIN
SET NOCOUNT ON;
SELECT
order_id,
order_date,
total_amount
FROM orders
WHERE customer_id = @CustomerId
AND (@StartDate IS NULL OR order_date >= @StartDate)
AND (@EndDate IS NULL OR order_date <= @EndDate)
ORDER BY order_date DESC;
END;
-- Call it: EXEC GetCustomerOrders @CustomerId = 101, @StartDate = '2026-01-01';
MERGE INTO customers AS target
USING staging_customers AS source
ON target.customer_id = source.customer_id
WHEN MATCHED THEN
UPDATE SET
target.customer_name = source.customer_name,
target.email = source.email,
target.updated_at = GETDATE()
WHEN NOT MATCHED THEN
INSERT (customer_id, customer_name, email, created_at)
VALUES (source.customer_id, source.customer_name, source.email, GETDATE());
#FACC15
rgb(250, 204, 21)
rgb(98%, 80%, 8%)
hsl(46, 96%, 53%)
hsv(46, 92%, 98%)
cmyk(0%, 18%, 92%, 2%)
CSV to JSON Converter (and JSON to CSV) — Free Online Tool
This tool converts CSV data to JSON, or JSON arrays back to CSV, handling quoted fields and embedded commas correctly. It's built for developers and analysts who need to convert CSV to JSON online for an API payload or config file, or who need to turn a JSON array of records back into a spreadsheet-friendly CSV. No spreadsheet software or script required — paste your data and convert in one click.
⚡ Key Takeaways
- Converts CSV to JSON and JSON back to CSV, correctly handling quoted commas.
- The CSV header row becomes the JSON object keys automatically.
- All CSV values convert to strings — adjust types afterward if JSON needs numbers.
- Mismatched JSON object keys are merged into one combined CSV header row.
What, Who, When & Why
| What it's for | Converts CSV data to JSON, or JSON arrays back to CSV, correctly handling quoted and comma-containing fields. |
|---|---|
| Who it's for | Developers and analysts moving data between spreadsheets and JSON-based APIs or config files. |
| When to use it | When your data is in one format but the system you're working with expects the other. |
| Why it's needed | Writing a script just to convert a one-off CSV or JSON payload is overkill; a dedicated converter handles it in seconds. |
| Best way to use it | Make sure your CSV has a header row before converting to JSON, since it's used directly as the object keys. |
How to Use the CSV ⇄ JSON Converter
- Paste your CSV data (with a header row) or JSON array into the Input box.
- Click CSV → JSON to convert CSV into a JSON array of objects, using the header row as keys.
- Or click JSON → CSV to convert a JSON array of objects into CSV rows.
- Review the result and the row/column count shown in the status message.
- Click Copy to grab the converted output.
Example: CSV to JSON
Given this CSV input:
id,name,city 1,Ada,Houston 2,Grace,Austin
Converting to JSON produces:
[
{ "id": "1", "name": "Ada", "city": "Houston" },
{ "id": "2", "name": "Grace", "city": "Austin" }
]
Running the JSON back through JSON → CSV reverses the process exactly, rebuilding the header row and comma-separated rows — useful for round-tripping data between a spreadsheet-friendly format and a JSON-consuming API or script.
Key Features
- CSV → JSON — converts CSV rows into an array of JSON objects using the header row as keys.
- JSON → CSV — converts a JSON array of objects back into CSV, automatically building a header row from all keys present.
- Correctly handles quoted fields, including commas and quotes embedded within a value.
- Status message showing exactly how many rows and columns were converted.
- Runs entirely in your browser — no data is uploaded to a server.
Practical Use Cases
- Preparing API test data: convert a CSV export into JSON for use in an API request body.
- Exporting JSON to spreadsheets: turn an API response (a JSON array) into CSV for opening in Excel or Google Sheets.
- Config file conversion: some tools expect JSON config while your source data is in CSV, or vice versa.
- Quick data inspection: convert a small JSON payload to CSV to eyeball it in a more familiar tabular format.
- Seeding test databases: convert a CSV of sample data into JSON for use in a test fixture or seed script.
Tips for Best Results
- Make sure your CSV includes a header row, since it's used directly as the JSON object keys.
- When converting JSON to CSV, check the resulting header row if your JSON objects have inconsistent keys, since missing values will appear as empty cells.
- Review numeric-looking values after CSV → JSON conversion if your destination system expects actual numbers rather than strings.
Related Terminology
CSV (comma-separated values) is a plain-text tabular format where each row is a line and each column is separated by a comma. JSON (JavaScript Object Notation) is a structured, key-value data format widely used in APIs and configuration files. When converting CSV to JSON, each row becomes one JSON object, and the header row's column names become the object's keys.
Important Considerations
All values from CSV are read as text strings — if your JSON needs numbers or booleans instead of strings, you may need to adjust types afterward, since a spreadsheet doesn't distinguish types the way JSON can. When converting JSON to CSV, if different objects in the array have different keys, the tool builds a header row from the union of all keys, leaving empty cells for missing values.
Related Tools
If your JSON needs escaping for safe embedding in HTML, try Escape / Unescape. For building test SQL data from your CSV instead, the SQL Value Generator can wrap values into a ready-to-use query fragment. To reformat delimiters before converting, use the Delim Converter.
Frequently Asked Questions
How do I convert CSV to JSON online?
Paste your CSV (including a header row) into the Input box and click "CSV → JSON" — the result is a JSON array of objects using your header row as the keys.
Does it handle commas inside quoted CSV fields correctly?
Yes, the parser correctly handles quoted fields that contain commas or embedded quotes, rather than naively splitting on every comma.
Can I convert a JSON array back into CSV?
Yes, click "JSON → CSV" with a JSON array of objects in the Input box, and it will generate a header row plus one CSV row per object.
Will number values in my CSV become numbers or strings in JSON?
All CSV values convert to strings by default, since CSV itself doesn't distinguish data types — you may need to adjust types afterward depending on your use case.
What happens if my JSON objects have different keys from each other?
The generated CSV header combines all keys found across every object, leaving empty cells for any object that doesn't have a particular key.
Tools for analysts, developers & QA engineers
33 free, browser-based utilities — text and list tools, SQL helpers, converters, and small productivity apps. Everything runs locally; nothing you type or paste is ever uploaded.
For Analysts
Clean lists, build SQL fragments, and reshape data without opening a spreadsheet.
For Developers
Format SQL, convert data formats, and handle everyday text and encoding tasks.
For QA Engineers
Generate test data, compare text output, and sanitize queries before sharing them.