Code Converter Toolkit avatar

Code Converter Toolkit

Pricing

Pay per usage

Go to Apify Store
Code Converter Toolkit

Code Converter Toolkit

A universal code conversion actor that transforms between 6 popular code formats in a single run. Supports both single and batch conversions with structured JSON output.

Pricing

Pay per usage

Rating

0.0

(0)

Developer

Jamshaid Arif

Jamshaid Arif

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

3 days ago

Last modified

Share

🔄 Code Converter Toolkit — Apify Actor

A universal code conversion actor that transforms between 6 popular code formats in a single run. Supports both single and batch conversions with structured JSON output.


Supported Conversions

#FromToKey
1HTMLMarkdownhtml_to_markdown
2MarkdownHTMLmarkdown_to_html
3CSSTailwind Classescss_to_tailwind
4SQL DDLORM Models (Python + JS)sql_to_orm
5JSONTypeScript Interfacesjson_to_typescript
6JSONPython Dataclassesjson_to_dataclass

Input Schema

Single Conversion (Default)

{
"conversion_type": "html_to_markdown",
"source_code": "<h1>Hello</h1><p>World</p>",
"root_class_name": "Root",
"orm_target": "both"
}
FieldTypeRequiredDefaultDescription
conversion_typestring (enum)"html_to_markdown"Which conversion to run
source_codestring(HTML demo)The source code to convert
root_class_namestring"Root"Class/interface name (JSON converters only)
orm_targetstring (enum)"both""both" / "sqlalchemy" / "sequelize"

Batch Conversion

Provide batch_conversions to run multiple conversions in one actor call.
When batch is provided, the single-mode fields are ignored.

{
"batch_conversions": [
{
"conversion_type": "html_to_markdown",
"source_code": "<h1>Title</h1><p>Paragraph</p>"
},
{
"conversion_type": "json_to_typescript",
"source_code": "{\"name\": \"Alice\", \"age\": 30}",
"root_class_name": "User"
},
{
"conversion_type": "css_to_tailwind",
"source_code": ".box { display: flex; padding: 1rem; gap: 0.5rem; }"
},
{
"conversion_type": "sql_to_orm",
"source_code": "CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(100) NOT NULL);",
"orm_target": "sqlalchemy"
}
]
}

Output

Each conversion produces a structured result in the default dataset:

{
"index": 0,
"conversion_type": "html_to_markdown",
"label": "HTML → Markdown",
"input_lang": "html",
"output_lang": "markdown",
"source_code": "<h1>Hello</h1>...",
"converted_output": "# Hello\n\n...",
"success": true,
"error": null,
"timestamp": "2025-01-15T12:00:00+00:00"
}

Additionally:

  • Key-Value Store → RUN_SUMMARY: Aggregated stats (total, success, fail counts)
  • Key-Value Store → OUTPUT_0_html_to_markdown.md: Individual output files with correct extensions

Conversion Details

1. HTML → Markdown

Converts semantic HTML into clean Markdown. Handles headings, bold/italic, links, images, code blocks, blockquotes, ordered/unordered lists, horizontal rules, and GFM-style tables.

2. Markdown → HTML

Parses Markdown syntax into semantic HTML5. Supports headings, inline formatting, fenced code blocks with language hints, blockquotes, lists, pipe tables, links, images, and horizontal rules.

3. CSS → Tailwind Classes

Maps 50+ CSS properties to Tailwind utility classes including display, position, flexbox, grid, spacing (margin/padding), typography, colors, borders, shadows, transforms, and more. Uses Tailwind's arbitrary value syntax [value] for unmapped values.

4. SQL → ORM Models

Parses CREATE TABLE DDL statements and generates:

  • Python SQLAlchemy ORM model classes
  • JavaScript Sequelize model definitions

Supports: INT, VARCHAR, TEXT, BOOLEAN, TIMESTAMP, SERIAL, JSON, UUID, BLOB, etc.
Constraints: PRIMARY KEY, NOT NULL, UNIQUE, DEFAULT, REFERENCES (foreign keys).

5. JSON → TypeScript Interfaces

Recursively infers TypeScript export interface definitions from JSON objects/arrays. Detects nested objects, arrays of objects (with singular naming), union types for mixed arrays, and optional fields for null values.

6. JSON → Python Dataclass

Generates Python @dataclass definitions with:

  • Recursive nested class generation
  • Optional[] typing for nullable fields
  • from_dict() classmethod with nested object reconstruction
  • to_dict() method (via dataclasses.asdict)
  • from_json() classmethod for direct string deserialization

Running Locally

# Install the Apify CLI
npm install -g apify-cli
# Navigate to the actor directory
cd apify-actor
# Create local storage
apify init
# Run with default input
apify run
# Run with custom input
apify run --input='{"conversion_type":"css_to_tailwind","source_code":".card{display:flex;padding:1rem;}"}'

Example Inputs by Type

HTML → Markdown

{
"conversion_type": "html_to_markdown",
"source_code": "<h1>Blog Post</h1><p>Hello <strong>world</strong>!</p><ul><li>Item 1</li><li>Item 2</li></ul>"
}

CSS → Tailwind

{
"conversion_type": "css_to_tailwind",
"source_code": ".container { display: flex; flex-direction: column; align-items: center; padding: 2rem; gap: 1rem; background-color: #ffffff; border-radius: 0.5rem; }"
}

SQL → ORM

{
"conversion_type": "sql_to_orm",
"source_code": "CREATE TABLE products (id SERIAL PRIMARY KEY, name VARCHAR(200) NOT NULL, price DECIMAL(10,2), category_id INTEGER REFERENCES categories(id), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);",
"orm_target": "both"
}

JSON → TypeScript

{
"conversion_type": "json_to_typescript",
"source_code": "{\"id\": 1, \"name\": \"Widget\", \"price\": 29.99, \"tags\": [\"sale\", \"new\"], \"dimensions\": {\"width\": 10, \"height\": 20}}",
"root_class_name": "Product"
}

JSON → Dataclass

{
"conversion_type": "json_to_dataclass",
"source_code": "{\"id\": 1, \"name\": \"Widget\", \"price\": 29.99, \"in_stock\": true, \"metadata\": null}",
"root_class_name": "Product"
}

Tech Stack

  • Runtime: Python 3.11
  • Platform: Apify SDK v2
  • Dependencies: Zero external deps for converters (stdlib only)
  • Docker: apify/actor-python:3.11

License

MIT