onnx2tf
A tool for converting ONNX files to LiteRT/TFLite/TensorFlow, PyTorch native code (nn.Module), TorchScript (.pt), state_dict (.pt), Exported Program (.pt2), and Dynamo ONNX. It also supports direct conversion from LiteRT to PyTorch.
What it is and what it does
onnx2tf is a model format converter that takes ONNX (Open Neural Network Exchange) files and translates them into multiple target frameworks: LiteRT (Google's edge ML runtime), TensorFlow/TFLite, PyTorch (as native nn.Module code or TorchScript), and other formats. It also works in reverse, converting LiteRT models back to PyTorch. The package uses two execution paths: flatbuffer_direct (the current default, optimized for speed and success rate) and tf_converter (a legacy path supporting a large set of ONNX operators). The tool is designed for developers who need to move trained models between frameworks—for instance, to deploy a PyTorch model on mobile via TFLite, or to run a TensorFlow model in PyTorch training pipelines.
The package depends on 18 runtime libraries covering ONNX tooling (onnx, onnxruntime, onnxsim, onnxoptimizer, onnxscript), ML frameworks (ai-edge-litert, flatbuffers), and utilities (numpy, opencv-python, protobuf, h5py). It requires Python 3.12 or later and is actively maintained. The conversion success depends on whether your model's layers are in the supported operator list; the documentation lists hundreds of ONNX operators with full or partial support status.
Use it for:
- Deploy a PyTorch model to mobile/edge devices by converting to LiteRT or TFLite format.
- Migrate a trained TensorFlow model to PyTorch for retraining or fine-tuning in a different framework.
- Convert ONNX models (from any framework) to TensorFlow for production serving.
- Optimize and simplify ONNX graphs before deployment using the built-in simplification and optimization tools.
- Export PyTorch models through ONNX as an intermediate step to reach non-PyTorch runtimes.
- Validate model compatibility across frameworks by round-tripping through ONNX and LiteRT.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts ONNX model files to LiteRT, TensorFlow, PyTorch, TorchScript, and other formats, with support for direct conversion from LiteRT back to PyTorch.
Yes, if you need to convert ONNX models to LiteRT, TensorFlow, or PyTorch. The package is actively maintained, has low install friction, and covers a broad set of ONNX operators. Check the supported operator list against your model's layers first—partial or missing support for specific ops may require workarounds. MIT license poses no restrictions. Not necessary if you work exclusively within one framework.
Install
onnx2tf on PyPI
pip
pip install onnx2tfuv
uv add onnx2tfpoetry
poetry add onnx2tfInstalling onnx2tf
Before you install
Low install friction with a pure Python wheel. Active maintenance—last commit 2026-08-01, 13 days old. Requires Python 3.12 or later. Pulls in 18 runtime dependencies including numpy, onnx, onnxruntime, and TensorFlow-adjacent libraries (ai-edge-litert, flatbuffers); dependency chain is substantial but standard for ML tooling.
License in practice
MIT license (permissive). No restrictions on commercial or proprietary use; you may use, modify, and distribute this package with minimal obligations.
Quickstart
pip install onnx2tf
from onnx2tf import onnx2tf
# Convert ONNX to LiteRT (default backend)
onnx2tf.convert(onnx_model_path='model.onnx', output_dir='./output')
Requires Python 3.12 or later. Conversion success depends on whether your ONNX model's layers are supported by the target backend (tf_converter or flatbuffer_direct).
Verify before relying
- Exact list of PyTorch export formats (nn.Module, TorchScript, state_dict, Exported Program, Dynamo ONNX) and their completeness/stability.
- Performance characteristics and conversion time for typical model sizes.
- Handling of unsupported ONNX operators and error recovery behavior.
- Whether flatbuffer_direct backend covers all use cases or if tf_converter fallback is still needed.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 18 — numpy, onnx, onnxruntime, opencv-python, onnxsim, onnxoptimizer, onnxscript, ai-edge-litert, sne4onnx, sng4onnx, psutil, protobuf, h5py, ml-dtypes, setuptools, flatbuffers, tqdm, pytest |
| Maintenance | actively maintained — 13 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,629,877/month — #3,706 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: onnx2tf-2.6.8-py3-none-any.whl
Keywords: onnx, tensorflow, tflite, litert, keras, pytorch, deep-learning, machine-learning
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
litert-torchConverts PyTorch models to .tflite format for…
permissive · top 15,000 on PyPI
netronNetron is a viewer for neural network and…
permissive · top 15,000 on PyPI
tf2onnxConverts TensorFlow, Keras, TensorFlow.js, and…
permissive · top 15,000 on PyPI
litert-converterConverts machine learning models to LiteRT…
permissive · top 15,000 on PyPI
onnx2torchConverts ONNX models to PyTorch modules with a…
permissive · top 15,000 on PyPI
tfliteParses TensorFlow Lite (*.tflite) model files…
permissive · top 15,000 on PyPI
pnnxExports and converts PyTorch neural network…
permissive · top 15,000 on PyPI
orbax-exportOrbax Export serializes JAX models to…
permissive · top 15,000 on PyPI
onnxmltoolsConverts machine learning models from multiple…
permissive · top 5,000 on PyPI
onnxconverter-commonProvides common utilities and functions for…
permissive · top 5,000 on PyPI