🌐
CodeConvert AI
codeconvert.ai β€Ί typescript-to-python-converter
Free TypeScript to Python Converter β€” AI Code Translation | CodeConvert AI
Instantly convert TypeScript to Python code with AI. Free, fast, and accurate code translation β€” 60+ languages supported, no signup required.
🌐
GitHub
github.com β€Ί TheLartians β€Ί TypeScript2Python
GitHub - TheLartians/TypeScript2Python: πŸšƒ Transpile TypeScript types to Python! A TypeScript to Python type transpiler.
πŸšƒ Transpile TypeScript types to Python! A TypeScript to Python type transpiler. - TheLartians/TypeScript2Python
Starred by 27 users
Forked by 3 users
Languages Β  TypeScript 91.3% | JavaScript 8.7%
Discussions

Side project for converting Python into TypeScript
I definitely recommend you get rid of all of the any types that it outputs. Even if it is just meant as a placeholder, it’s actually worse than not having anything there, because Typescript won’t try to infer the types. In effect, it becomes just JavaScript with pointless Typescript syntax. More on reddit.com
🌐 r/typescript
43
106
December 26, 2020
Are there any tools to transform a large Typescript project into Python? Maybe a transpiler or something?
There are at least two big issues with this: Semantics: Javascript and Python are similar, being dynamic, garbage collected languages. But there is an incredible amount of subtlety to the way both languages behave. You'd end up needing to write your own runtime library to emulate javascript, which is known for many weird quirks. Maybe you could accomplish in a way where the resulting code is readable, but everything would still rely on your support library which provides non-standard behaviors for everything. Libraries: Both languages are known for their rich ecosystems. What libraries does your project use? Maybe you could compile the libraries as well, but what if they're native bindings? At minimum, you'd almost certainly need to provide some emulation for node/deno/bun/whatever runtime you're using. More on reddit.com
🌐 r/Compilers
6
0
May 29, 2025
Python equivalent of Typescript interface - Stack Overflow
For the code completion and type hinting in IDEs, just add static typing for the Person and Address classes and you are already good to go. Assuming you use the latest python3.6, here's a rough equivalent of the typescript classes from your example: More on stackoverflow.com
🌐 stackoverflow.com
AWS CDK Python

I'm in a meeting with the CDK team right now and made them aware of this thread. The plan is to convert all of the TypeScript to Python to make very clear that Python is a first-class CDK citizen.

You should also read AWS CDK in Other Languages to learn how to translate from TypeScript to other languages.

More on reddit.com
🌐 r/aws
14
16
July 25, 2019
People also ask

Can I convert TypeScript to Python automatically?
Yes. DocuWriter.ai's AI-powered converter analyzes your TypeScript code and generates equivalent Python code. It handles syntax differences (C-style to Indentation-based), type system changes (Static, strong to Dynamic, strong), and common library mappings. Always review the output β€” automated conversion is a starting point, not a finished product.
🌐
docuwriter.ai
docuwriter.ai β€Ί typescript-to-python-code-converter
typescript to python - Code Converter
Can I also convert Python back to TypeScript?
Yes! CodeConvert AI supports bidirectional conversion. You can convert Python to TypeScript just as easily by using our Python to TypeScript converter.
🌐
codeconvert.ai
codeconvert.ai β€Ί typescript-to-python-converter
Free TypeScript to Python Converter β€” AI Code Translation | ...
Can I also convert TypeScript back to Python?
Yes! CodeConvert AI supports bidirectional conversion. You can convert TypeScript to Python just as easily by using our TypeScript to Python converter.
🌐
codeconvert.ai
codeconvert.ai β€Ί python-to-typescript-converter
Free Python to TypeScript Converter β€” AI Code Translation | ...
🌐
PyPI
pypi.org β€Ί project β€Ί ts2python
ts2python
JavaScript is disabled in your browser. Please enable JavaScript to proceed Β· A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Docuwriter
docuwriter.ai β€Ί typescript-to-python-code-converter
typescript to python - Code Converter
Open the converter above and paste your TypeScript source code into the input editor. ... Select Python as the target language and click Convert to start the AI translation.
🌐
CodeConvert AI
codeconvert.ai β€Ί python-to-typescript-converter
Free Python to TypeScript Converter β€” AI Code Translation | CodeConvert AI
For complex or performance-critical code, we recommend reviewing and testing the output. ... Yes! CodeConvert AI supports bidirectional conversion. You can convert TypeScript to Python just as easily by using our TypeScript to Python converter.
Find elsewhere
🌐
Codeporting
products.codeporting.ai β€Ί convert β€Ί typescript-to-python
AI-Powered TypeScript to Python Snippet Converter
Conversion TypeScript to Python using AI involves utilizing natural language processing (NLP) techniques and machine learning algorithms to analyze and understand the TypeScript code, source-to-source code translation may save your time
🌐
Reddit
reddit.com β€Ί r/typescript β€Ί side project for converting python into typescript
r/typescript on Reddit: Side project for converting Python into TypeScript
December 26, 2020 - TypeScript -> Python ... I once had to deal with a codebase that was a Java->PHP auto conversion. It's suuuper dicy to do this. One of the benefits of using a strongly typed language like Java or Typescript is that you can avoid explicit type checking, since the language does that for you. When you convert ...
🌐
PyPI
pypi.org β€Ί project β€Ί ts2py
ts2py Β· PyPI
January 17, 2023 - Transpiles TypeScript-Interface-definitions to Python TypedDicts Β· This repo is born as a fork of ts2python written by Eckhart Arnold arnold@badw.de, Bavarian Academy of Sciences and Humanities. The reason behind this fork was that I needed a simpler way to quickly convert TypeScript interfaces to Python TypedDict.
      Β» pip install ts2py
    
Published Β  Jan 17, 2023
Version Β  0.0.2
🌐
CodingFleet
codingfleet.com β€Ί code-converter β€Ί typescript β€Ί python
TypeScript to Python Converter - CodingFleet
Convert your TypeScript Code to Python. This exceptional AI-powered tool converts your TypeScript code into Python code easily, eliminating the need for manual re-coding. Save your precious time and unlock cross-platform development like never before with our converter tool.
🌐
Freemediatools
freemediatools.com β€Ί typescripttopython
FREE TypeScript to Python Converter Online Tool in Browser
Instantly convert TypeScript code to Python. Professional-grade transpiler supporting modern TS features, classes, interfaces, and async operations.
🌐
Reddit
reddit.com β€Ί r/compilers β€Ί are there any tools to transform a large typescript project into python? maybe a transpiler or something?
r/Compilers on Reddit: Are there any tools to transform a large Typescript project into Python? Maybe a transpiler or something?
May 29, 2025 - ComPy (Compiled Python) – Python-to-C++ Transpiler | Initial Release v1.0.0 coming soon (Requesting Feedback/Criticism) ... Typo: A Programming Language using TypeScript's Type System!
🌐
GitHub
github.com β€Ί PerryBhandal β€Ί dts_py_transform
GitHub - PerryBhandal/dts_py_transform: Convert Typescript definition files into Python 3 (compliant with PEP-484)
April 15, 2019 - Create a repo which automatically converts all Definitely Typed type annotations into their Python 3 equivalents, along with an easy tool for installing said definitions. Create an easy way to have interop between Python and Javascript, along ...
Forked by 2 users
🌐
AlgoDaily
algodaily.com β€Ί convert β€Ί ts β€Ί python
AlgoDaily - Daily coding interview questions. Full programming interview prep course and software career coaching.
Programming interview prep bootcamp with coding challenges and practice. Daily coding interview questions. Software interview prep made easy.
Top answer
1 of 9
61

For the code completion and type hinting in IDEs, just add static typing for the Person and Address classes and you are already good to go. Assuming you use the latest python3.6, here's a rough equivalent of the typescript classes from your example:

# spam.py
from typing import Optional, Sequence


class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]

    def __init__(self, street: str, housenumber: int, 
                 housenumber_postfix: Optional[str] = None) -> None:
        self.street = street
        self.housenumber = housenumber
        self.housenumber_postfix = housenumber_postfix


class Person:
    name: str
    adresses: Sequence[Address]

    def __init__(self, name: str, adresses: Sequence[str]) -> None:
        self.name = name
        self.adresses = adresses


person = Person('Joe', [
    Address('Sesame', 1), 
    Address('Baker', 221, housenumber_postfix='b')
])  # type: Person

I suppose the boilerplate you mentioned emerges when adding the class constructors. This is indeed inavoidable. I would wish default constructors were generated at runtime when not declared explicitly, like this:

class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]


class Person:
    name: str
    adresses: Sequence[Address]


if __name__ == '__main__':
    alice = Person('Alice', [Address('spam', 1, housenumber_postfix='eggs')])
    bob = Person('Bob', ())  # a tuple is also a sequence

but unfortunately you have to declare them manually.


Edit

As Michael0x2a pointed out in the comment, the need for default constructors is made avoidable in python3.7 which introduced a @dataclass decorator, so one can indeed declare:

@dataclass
class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]


@dataclass
class Person:
    name: str
    adresses: Sequence[Address]

and get the default impl of several methods, reducing the amount of boilerplate code. Check out PEP 557 for more details.


I guess you could see stub files that can be generated from your code, as some kind of interface files:

$ stubgen spam  # stubgen tool is part of mypy package
Created out/spam.pyi

The generated stub file contains the typed signatures of all non-private classes and functions of the module without implementation:

# Stubs for spam (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Optional, Sequence

class Address:
    street: str
    housenumber: int
    housenumber_postfix: Optional[str]
    def __init__(self, street: str, housenumber: int, housenumber_postfix: Optional[str]=...) -> None: ...

class Person:
    name: str
    adresses: Sequence[Address]
    def __init__(self, name: str, adresses: Sequence[str]) -> None: ...

person: Person

These stub files are also recognized by IDEs and if your original module is not statically typed, they will use the stub file for type hints and code completion.

2 of 9
24

A TypeScript interface describes a JavaScript object. Such an object is analogous to a Python dictionary with well-known string keys, which is described by a TypedDict.

TypeScript interface example

For example the TypeScript interface:

interface Address {
    street: string;
    housenumber: number;
}

will describe JavaScript objects like:

var someAddress = {
    street: 'SW Gemini Dr.',
    housenumber: 9450,
};

Python TypedDict example

The equivalent Python TypedDict:

from typing import TypedDict

class Address(TypedDict):
    street: str
    housenumber: int

will describe Python dictionaries like:

some_address = {
    'street': 'SW Gemini Dr.',
    'housenumber': 9450,
}

# or equivalently:

some_address = dict(
    street='SW Gemini Dr.',
    housenumber=9450,
)

These dictionaries can be serialized to/from JSON trivially and will conform to the analogous TypeScript interface type.

Note: If you are using Python 2 or older versions of Python 3, you may need to use the older function-based syntax for TypedDict:

from mypy_extensions import TypedDict

Address = TypedDict('Address', {
    'street': str,
    'housenumber': int,
})

Alternatives

There are other ways in Python to represent structures with named properties.

Data classes, available in Python 3.7, have read-write keys. However they cannot be serialized to/from JSON automatically.

from dataclasses import dataclass

@dataclass
class Address:
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)

Named tuples are cheap and have read-only keys. They also cannot be serialized to/from JSON automatically.

from typing import NamedTuple

class Address(NamedTuple):
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)

Simple namespaces, available in Python 3.3, are similar to data classes but are not very well known.

from types import SimpleNamespace

class Address(SimpleNamespace):
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)

attrs is a long-standing third-party library that is similar to data classes but with many more features. attrs is recognized by the mypy typechecker.

import attrs

@attr.s(auto_attribs=True)
class Address:
    street: str
    housenumber: int

my_address = Address(
    street='SW Gemini Dr.',
    housenumber=9450,
)
🌐
Javainuse
javainuse.com β€Ί js2py
Online JavaScript to Python Converter
JavaScript, often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant ...
🌐
CodeConvert AI
codeconvert.ai β€Ί javascript-to-python-converter
Free JavaScript to Python Converter β€” AI Code Translation | CodeConvert AI
Instantly convert JavaScript to Python code with AI. Free, fast, and accurate code translation β€” 60+ languages supported, no signup required.
🌐
Stevs
stevs.net β€Ί converter
Web Code Converter
Quickly convert HTML, CSS and Javascript into Javascript, Typescript, React, PHP, VBScript, ASP, Perl, Python, Ruby, Lisp and more with the Web Code Converter. Take the hard work out of coding HTML to Javascript. Web designers love the Web Code Converter.