data-csv-to-json Edge Function — Data
DataConverts a CSV string to a typed JSON array, automatically inferring numbers, booleans, and null values from string fields.
Edge function data-csv-to-json Converts a CSV string to a typed JSON array, automatically inferring numbers, booleans, and null values from string fields.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.
npx aerostack add navin/data-csv-to-json Use with AI Assistants
MCPConnect Claude, Cursor, or any MCP-compatible client — then call this function by slug
① Add MCP Server
Add this once — access all Aerostack functions from your AI tool.
{
"mcpServers": {
"aerostack": {
"url": "https://mcp.aerostack.dev",
"type": "http"
}
}
} ② Call this function
Ask your AI to use the call_function tool with this slug:
call_function({
slug: "data-csv-to-json",
args: {
"csv": "example_csv",
"delimiter": ",",
"inferTypes": true
}
}) data-csv-to-json — CSV to typed JSON array
Converts a CSV string to a typed JSON array, auto-inferring numbers, booleans, and null values.
API
POST /api/data-csv-to-json
Request body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
csv |
string |
✅ | — | The CSV string to convert |
delimiter |
string |
❌ | ',' |
Field delimiter |
inferTypes |
boolean |
❌ | true |
Auto-cast numbers, booleans, null |
Type inference rules (when inferTypes=true):
- Empty string →
null "true"/"false"→boolean- Numeric strings →
number - Everything else →
string
Success response (200)
{
"success": true,
"data": {
"data": [{ "name": "Alice", "age": 30, "active": true }],
"headers": ["name", "age", "active"],
"rowCount": 1
}
}
Error responses
| Code | HTTP | When |
|---|---|---|
INVALID_INPUT |
400 | Missing csv field |
INTERNAL_ERROR |
500 | Unexpected error |
Usage
cURL
curl -X POST "$FUNCTION_URL" \
-H "Content-Type: application/json" \
-d '{"csv": "name,age,active\nAlice,30,true"}'
TypeScript / JavaScript (HTTP)
const response = await fetch(FUNCTION_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ csv: csvString, inferTypes: true }),
});
const { data } = await response.json();
console.log(data.data);
Direct import (Node / Bun / Deno)
import { csvToJson } from '@aerostack/functions/data-csv-to-json';
const { data, headers } = csvToJson({ csv: myCsvString });
Use Cases
- Converting spreadsheet exports to JSON before inserting into a database
- Processing CSV data from third-party integrations (analytics exports, CRM dumps)
- Feeding CSV data into an AI workflow that expects typed JSON
Notes
- Type inference applies to the trimmed value —
" 30 "becomes30(number) - Set
inferTypes: falseto keep all values as strings - First row is always treated as the header row
Metadata
Tags
Publisher
@navin verified
Build and publish your own functions
Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.
More Data Functions
Browse Data Functions →data-aggregate-stats
by @navin
Computes descriptive statistics (count, sum, min, max, mean, median, stdDev, variance, percentiles) for an array of numbers.
data-array-group-by
by @navin
Groups an array of objects into a map keyed by the value of a specified property. Zero dependencies.
data-csv-parse
by @navin
Parses a CSV string into an array of row objects with headers, handling quoted fields, custom delimiters, and escaped characters.
data-deep-diff
by @navin
Computes a structural deep diff between two JSON-serializable values, classifying each change as added, removed, or modified.
data-sort-objects
by @navin
Sorts an array of objects by one or more fields with configurable direction, null handling, and nested field dot-notation support.
data-dedupe-array
by @navin
Removes duplicate items from an array using strict equality for primitives, deep equality for objects, or a key field for object arrays.
Frequently asked questions
What does the data-csv-to-json function do? +
data-csv-to-json is a serverless edge function for data automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.
How do I deploy the data-csv-to-json function? +
Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/data-csv-to-json ``` It will be live on Cloudflare Workers in seconds.
What runtime does data-csv-to-json use? +
data-csv-to-json runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.
Can I customise the data-csv-to-json function? +
Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.