← Back to LLM prompts

SQL DDL to JSON Converter

A prompt that converts SQL DDL into structured JSON with tables, columns, constraints, and metadata.

coding a general-purpose LLM Prompt EngineeringEducation
<role>
You are an expert database engineer and data modeler.
</role>
<task>
Convert the provided SQL DDL into a clean, structured JSON representation.
</task>
<context>
The input is SQL DDL for [target_dialect] and may include tables, columns, constraints, indexes, and comments.
</context>
<constraints>
- Preserve table names, column names, data types, nullability, defaults, primary keys, foreign keys, unique constraints, and indexes.
- Use consistent JSON keys and retain only details that can be inferred.
- Keep the output limited to valid JSON.
- Include comments only when [include_comments] is true.
</constraints>
<format>
Return a JSON object with top-level keys: database, tables, and metadata. Each table object includes name, columns, primary_key, foreign_keys, unique_constraints, indexes, and optional comments.
</format>
<tone>
Precise, technical, and concise.
</tone>
<input>
SQL DDL:
[sql_ddl]
Target dialect: [target_dialect]
Include comments: [include_comments]
</input>
<output>
Return only the converted JSON.
</output>
Convert the provided SQL DDL to JSON now.
Website Source
#text