Skip to content
data-type-converter logo

Data Type Converter

data-type-converter

Convert between data formats (JSON, CSV, XML, YAML, TOML). Handles nested structures, arrays, and preserves data types where possible.

SKILL.md

Full skill instructions

Data Type Converter

Convert data between JSON, CSV, XML, YAML, and TOML formats. Handles nested structures, arrays, and complex data with intelligent flattening options.

Quick Start

from scripts.data_converter import DataTypeConverter

# JSON to CSV
converter = DataTypeConverter()
converter.convert("data.json", "data.csv")

# YAML to JSON
converter.convert("config.yaml", "config.json")

# With options
converter.convert("data.json", "data.csv", flatten=True)

Features

  • 5 Formats: JSON, CSV, XML, YAML, TOML
  • Nested Data: Flatten or preserve nested structures
  • Arrays: Handle array data intelligently
  • Type Preservation: Maintain data types where possible
  • Pretty Output: Formatted, human-readable output
  • Batch Processing: Convert multiple files

API Reference

Basic Conversion

converter = DataTypeConverter()

# Auto-detect format from extension
converter.convert("input.json", "output.csv")
converter.convert("input.xml", "output.json")
converter.convert("input.yaml", "output.toml")

With Options

# Flatten nested structures for CSV
converter.convert("nested.json", "flat.csv", flatten=True)

# Pretty print output
converter.convert("data.json", "pretty.json", indent=4)

# Specify root element for XML
converter.convert("data.json", "data.xml", root="records")

Programmatic Access

# Load and convert in memory
data = converter.load("data.json")
converter.save(data, "data.yaml")

# String conversion
json_str = '{"name": "John", "age": 30}'
yaml_str = converter.convert_string(json_str, "json", "yaml")

Batch Processing

# Convert all JSON files to CSV
converter.batch_convert(
    input_dir="./​json_files",
    output_dir="./​csv_files",
    output_format="csv"
)

CLI Usage

# Basic conversion
python data_converter.py --input data.json --output data.csv

# With flattening
python data_converter.py --input nested.json --output flat.csv --flatten

# Batch convert
python data_converter.py --input-dir ./​json --output-dir ./​csv --format csv

# Pretty print
python data_converter.py --input data.json --output pretty.json --indent 4

CLI Arguments

ArgumentDescriptionDefault
--inputInput fileRequired
--outputOutput fileRequired
--input-dirInput directory for batch-
--output-dirOutput directory-
--formatOutput formatFrom extension
--flattenFlatten nested dataFalse
--indentIndentation spaces2
--rootXML root elementroot

Conversion Matrix

From/​ToJSONCSVXMLYAMLTOML
JSON-YesYesYesYes
CSVYes-YesYesYes
XMLYesYes-YesYes
YAMLYesYesYes-Yes
TOMLYesYesYesYes-

Examples

JSON to CSV (Flat)

converter = DataTypeConverter()

# Input: data.json
# [{"name": "John", "age": 30}, {"name": "Jane", "age": 25}]

converter.convert("data.json", "data.csv")

# Output: data.csv
# name,age
# John,30
# Jane,25

Nested JSON to Flat CSV

# Input: nested.json
# [{"user": {"name": "John", "email": "[email protected]"}, "orders": 5}]

converter.convert("nested.json", "flat.csv", flatten=True)

# Output: flat.csv
# user.name,user.email,orders
# John,[email protected],5

YAML Config to JSON

# Input: config.yaml
# database:
#   host: localhost
#   port: 5432
# debug: true

converter.convert("config.yaml", "config.json")

# Output: config.json
# {"database": {"host": "localhost", "port": 5432}, "debug": true}

XML to JSON

# Input: data.xml
# <users>
#   <user><name>John</​name><age>30</​age></​user>
# </​users>

converter.convert("data.xml", "data.json")

# Output: data.json
# {"users": {"user": {"name": "John", "age": "30"}}}

Dependencies

pyyaml>=6.0
toml>=0.10.0
xmltodict>=0.13.0
pandas>=2.0.0

Limitations

  • CSV doesn't support nested data (requires flattening)
  • XML attribute handling is basic
  • TOML doesn't support null values
  • Very deep nesting may cause issues with some formats
  • Array handling varies by format

More Other skills

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

179.7K 76.1K
View

Fundamental design principles for writing maintainable, testable Python code.

40.2K 21.9K
View

Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.

40.2K 20K
View

Generate Playwright tests from scenarios using interactive browser exploration and validation.

39.7K 18.2K
View

Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.

40.2K 14.7K
View

GDPR-compliant data handling with consent management, data subject rights, and privacy controls.

40.2K 14.3K
View

Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.

40.2K 13.5K
View

Detailed multi-file refactor planning with safety checks and rollback guidance.

39.7K 13K
View