FormatArc JSON Formatter conversion resultFormatArc JSON Formatter conversion result
Published: 2026-03-20Updated: 2026-04-27

formatarc — Format JSON, YAML & CSV from the Terminal (npm / npx)

Run npx formatarc to format JSON, convert YAML, CSV, Markdown, and HTML from your terminal. Import it as an API in Node.js projects — no browser needed.

The data conversion features of FormatArc are now available as an npm package. You can format JSON and convert YAML, CSV, Markdown, and HTML right from your terminal or Node.js code — no browser needed.

This article covers how to use formatarc as a CLI tool and how to integrate it into your project as an API.

Installation

Run instantly with npx (no install required)

For a quick one-off conversion, npx is the easiest option. No installation needed.

npx formatarc json-format '{"name":"FormatArc","version":1}'

Global install

If you use it frequently, install it globally to skip the npx startup delay.

npm install -g formatarc

After installation, the formatarc command is available directly.

formatarc json-format '{"name":"FormatArc","version":1}'

Add to your project

To use it as a dependency in a Node.js project:

npm install formatarc

Supported tools

Seven conversion tools are available — the same ones found on the FormatArc website (Markdown tools added in v0.2.0).

Tool Description
json-format Pretty-print and validate JSON
yaml-to-json Convert YAML to JSON
json-to-yaml Convert JSON to YAML
csv-to-json Convert CSV to JSON (header row required)
csv-to-markdown Convert CSV to a Markdown (GFM) table
markdown-to-html Convert Markdown to HTML
html-to-markdown Convert HTML to Markdown

CLI usage

The basic syntax is:

formatarc <tool> [input]

There are three ways to pass input.

1. Inline argument

formatarc json-format '{"name":"FormatArc","tools":["json","yaml","csv"]}'

Output:

{
  "name": "FormatArc",
  "tools": [
    "json",
    "yaml",
    "csv"
  ]
}

2. File path

formatarc yaml-to-json config.yaml

Pass a file path and formatarc reads and converts its contents. This works well in CI/CD pipelines.

3. Pipe from stdin

cat data.csv | formatarc csv-to-json

Combine it with curl to format API responses on the fly. If you want to compare formatarc with jq and python -m json.tool, see curl pretty-print JSON: 4 one-liners.

curl -s https://api.example.com/data | formatarc json-format

Working with Markdown and HTML

Drop a CSV into a Markdown table for a GitHub README or a docs page:

cat users.csv | formatarc csv-to-markdown

Render Markdown as HTML for blog platforms that don't accept Markdown directly:

cat README.md | formatarc markdown-to-html > README.html

Or strip HTML down to clean Markdown — perfect when feeding web pages into LLMs:

curl -s https://example.com/article | formatarc html-to-markdown

Using the API

You can also call the conversion functions directly from Node.js code. This is useful for automation scripts or when building your own tools.

The convert function

convert takes a tool name and an input string, and returns the conversion result.

import { convert } from "formatarc";

const result = convert("json-format", '{"a":1,"b":2}');
console.log(result.output);
// {
//   "a": 1,
//   "b": 2
// }

The return value has two fields: output (the converted result) and error (the error message).

const result = convert("json-format", "{invalid json}");
if (result.error) {
  console.error(result.error);
  // JSON parse error: Expected property name or '}' ...
}

On error, output is an empty string and error contains the message. On success, error is an empty string.

The isValidTool function

A type guard that checks whether a string is a valid tool name.

import { convert, isValidTool } from "formatarc";

const toolName = process.argv[2];

if (isValidTool(toolName)) {
  const result = convert(toolName, inputData);
  console.log(result.output);
}

Example: batch-convert YAML files to JSON

import { convert } from "formatarc";
import { readFileSync, writeFileSync } from "fs";
import { globSync } from "fs";

const files = globSync("configs/*.yaml");

for (const file of files) {
  const yaml = readFileSync(file, "utf-8");
  const result = convert("yaml-to-json", yaml);

  if (result.error) {
    console.error(`${file}: ${result.error}`);
    continue;
  }

  const outPath = file.replace(/\.yaml$/, ".json");
  writeFileSync(outPath, result.output);
  console.log(`${file} → ${outPath}`);
}

Using the browser version

If you prefer a visual interface over the terminal, the FormatArc website handles everything in the browser. No data is sent to any server.