# File Convert

> File format conversion between CSV, JSON, and Markdown. Use when the user needs to convert a CSV to JSON, convert JSON to CSV, turn a spreadsheet export into JSON, flatten JSON into a CSV, parse a Markdown file's frontmatter into JSON, generate a Markdown file with YAML frontmatter from JSON, or convert data between these formats. Triggers include "convert CSV to JSON", "csv to json", "ubah csv ke json", "convert JSON to CSV", "json to csv", "flatten JSON to CSV", "parse frontmatter", "markdown to json", "md to json", "json to markdown", "extract frontmatter", "convert this file", "konversi file", "change file format", or any task requiring CSV/JSON/Markdown interconversion.

- Skill: `lazuardytech/file-convert` (Agent Skill, multi-file: 10 files)
- Install (CLI): `npx skillmds@latest add lazuardytech/file-convert`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lazuardytech/file-convert/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- License: MIT
- Author: lazuardytech (https://skillmd.com/u/lazuardytech)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/lazuardytech/file-convert

---


# file-convert

Convert data between CSV, JSON, and Markdown (YAML frontmatter + body).

Run CLIs from this skill's directory (the folder that contains this `SKILL.md`):
`uv run scripts/<name>.py`. Do not prefix `skills/file-convert/`.

## Available Scripts

### Unified CLI

```bash
uv run scripts/convert.py data.csv --from csv --to json
```

`--from`/`--to` accept `csv`, `json`, `md`. Supported directions:
`csv→json`, `json→csv`, `md→json`, `json→md`. Reads `-` for stdin.

### CSV → JSON

```bash
uv run scripts/csv_to_json.py data.csv          # infers int/float/bool/null
uv run scripts/csv_to_json.py data.csv --no-infer   # keep strings
```

Streams rows via `csv.DictReader`; emits a JSON array. `--delimiter` to change separator.

### JSON → CSV

```bash
uv run scripts/json_to_csv.py data.json         # flattens nested keys (a.b.c)
uv run scripts/json_to_csv.py data.json --no-flatten  # nested → JSON strings
```

Accepts a JSON array of objects (or a single object). Header is the union of keys.

### Markdown → JSON

```bash
uv run scripts/md_to_json.py post.md
```

Splits YAML frontmatter (between `---` fences) from the body. Emits
`{"frontmatter": {...}, "body": "..."}`.

### JSON → Markdown

```bash
uv run scripts/json_to_md.py post.json
```

Reads `{"frontmatter": {...}, "body": "..."}` and writes a Markdown doc with a
YAML frontmatter block followed by the body.

## Round-trip

`csv → json → csv` and `json → md → json` preserve data when flattening is off
or keys have no dots. `unflatten()` cannot rebuild JSON arrays (list indices
become dict keys).

## Output & Exit Codes

- Converters write their result to stdout; diagnostics to stderr.
- Exit `0` success, `1` error, `2` file not found.

## Notes

- CSV↔JSON is standard-library only. Markdown conversion pulls in PyYAML via a
  PEP 723 inline dependency (correct YAML beats a hand-rolled parser).

