---
name: convert
description: File format conversion and transformation CLI between images, PDFs, documents, CSV, and data formats.
---

# convert

## Description

File format conversion skill with AI-powered extraction capabilities. Converts between images, PDFs, documents, and data formats with optional quality control and AI cleanup.

This CLI is API-backed. Set `SKILL_API_KEY` when routing through the hosted skills/connectors runtime; provider-specific keys are managed by that runtime.

## Category

File Processing / Format Conversion

## Commands

### convert
Convert a single file to another format.

```bash
bun run src/index.ts convert <input> --format <fmt> [options]
```

Options:
- `--format <fmt>` - Target format (required)
- `--output <path>` - Output file path
- `--quality <preset>` - Quality preset (lossless, high, medium, low, web)
- `--clean` - AI cleanup/sanitization
- `--model <model>` - AI model (claude, gpt-4o)

### batch
Convert multiple files in a directory.

```bash
bun run src/index.ts batch <dir> --format <fmt> --output <outdir> [options]
```

### info
Display file information.

```bash
bun run src/index.ts info <file>
```

### formats
List all supported formats and conversion matrix.

```bash
bun run src/index.ts formats
```

## Dependencies

### NPM Packages
- `sharp` - Image processing
- `pdf-lib` - PDF manipulation
- `pdf-parse` - PDF text extraction
- `mammoth` - DOCX parsing
- `exceljs` - Excel file handling
- `csv-parse/csv-stringify` - CSV processing
- `@anthropic-ai/sdk` - Claude AI
- `openai` - GPT-4o AI

### API Key
- `SKILL_API_KEY` - Hosted runtime access. Provider credentials for AI features are managed remotely.

## Conversion Categories

### Image Processing
- Format conversion (PNG, JPG, WebP, AVIF, GIF, TIFF)
- Quality optimization (5 presets)
- Resize support
- Images to PDF

### Document Processing
- PDF to text/markdown
- DOCX to markdown/text/HTML
- HTML to markdown
- Markdown to HTML

### Data Processing
- CSV to/from Excel, JSON, YAML
- JSON to/from YAML
- TSV conversions

### AI-Powered
- Image OCR to markdown/text/JSON
- PDF extraction with AI cleanup
- Document cleaning/sanitization

## Key Features

1. **Quality Presets**: lossless, high, medium, low, web
2. **AI Cleanup**: `--clean` flag sanitizes output with AI
3. **Large File Chunking**: Automatic splitting for files >10MB
4. **Batch Processing**: Convert entire directories

## Use Cases

1. **Image Optimization**: Compress images for web
2. **Document Extraction**: OCR scanned documents
3. **Data Transformation**: Convert between data formats
4. **PDF Processing**: Extract/convert PDF content
