About this converter
This free tool converts TypeScript into Python dataclass. TypeScript interface or type alias. Standard library dataclass for Python. The conversion runs entirely client-side: your input is not uploaded or logged. Useful when you want to skip writing types by hand for an API response, a database row, or a config payload.
Why convert TypeScript to Python dataclass
- • Use stdlib dataclasses to model structured data without extra deps.
- • Get __init__ / __repr__ / __eq__ for free, in a few lines.
- • Migrate from dicts to typed objects without buying into a framework.
How to use
- Paste your TypeScript on the left panel, or pick one of the sample tabs above.
- The converter infers field names, optionality, and types automatically.
- Copy the generated Python dataclass on the right and drop it straight into your codebase.
Common pitfalls
- • Inferred types only see the payload you pasted. Add nullable / optional flags for fields that can be missing.
- • Numeric types are inferred as integer or float based on the sample. Real APIs sometimes return both — widen to a number/float type when in doubt.
- • Empty arrays default to an `unknown` element type. Paste a non-empty sample to get a meaningful element type.