iTranslated by AI
I built a tool to generate OpenAPI (Swagger) specifications from JSON in seconds
Introduction
In API development, writing OpenAPI (Swagger) specifications is an unavoidable task, but honestly, it's tedious, isn't it?
Especially when you already have an implemented API or an external API response example (JSON), there are many times when you think, "I want to convert this JSON structure directly into a YAML schema definition."
Handwriting type: object or nesting properties takes time and is prone to indentation errors.
Therefore, I created a tool that converts JSON into an OpenAPI Schema object (YAML) instantly just by pasting it.
What kind of tool?
"JSON to OpenAPI Converter" is a developer tool that runs in the browser.
When you paste JSON into the area on the left, an OpenAPI 3.0 / 3.1 compliant YAML schema is generated in real-time on the right.
Features
- ⚡ Real-time conversion: It converts as you type, so there's no waiting time.
-
📝 Accurate type inference: It automatically identifies strings (
string), numbers (number/integer), booleans (boolean), arrays (array), and objects (object). - 🌳 Supports deep nesting: It recursively analyzes complex JSON structures and outputs them with correct indentation.
- 📋 One-click copy: The generated YAML can be copied to the clipboard with a single button.
How to use
The usage is very simple.
- Access JSON to OpenAPI Converter.
- Paste the JSON you want to convert into the text area on the left.
- The generated YAML will be displayed on the right, so copy and paste it into your OpenAPI definition file (such as
openapi.yaml).
Conversion Example
For example, if you input JSON like the following:
{
"id": 123,
"name": "User Name",
"tags": ["admin", "editor"],
"profile": {
"active": true
}
}
The following YAML will be generated:
type: object
properties:
id:
type: integer
name:
type: string
tags:
type: array
items:
type: string
profile:
type: object
properties:
active:
type: boolean
Conclusion
Creating API specifications should be focused on "essential design" rather than being consumed by the task of "writing YAML."
I would be happy if this tool helps improve the efficiency of your daily development work, even just a little.
DevToolkits also offers other tools to make an engineer's "small tasks" easier. Please check them out.
Discussion