Code Converter

Commercial use OK 568 models No watermark No sign-up needed
Model:
+ GPT-5, Claude, Gemini
Paste code in one language, pick the target, and get back equivalent idiomatic code in 16+ target languages - Python, JavaScript, TypeScript, Go, Rust, Java, C++, C#, Ruby, PHP, Swift, Kotlin, Shell, SQL. Toggle literal-translation vs idiomatic-rewrite, preserve comments, or force the target language's stdlib.
Behavior preserved
Ctrl+Enter to submit · Tab inserts spaces 0 / 12,000

Drop a source file (up to 500KB) - we'll paste it into the code field.

-
Paste code to translate.
Converted code
Run in Coder

        
Migration notes
Advanced options
Result
Tokens running low. Get More Tokens
Want better results? Premium models (GPT-5, Claude, Gemini) deliver higher quality. View Plans

❤️ Love Free.ai? Tell your friends!

Sign up to get a referral link and earn 30,000 tokens per friend.

Want more? Sign up free: 30,000 tokens/day
Sign Up Free

Processing your request...

Convert code between programming languages with AI.

How to Use Code Converter

1
Enter your input

Type text, upload a file, or describe what you want. No account needed.

2
Click generate

Our AI processes your request in seconds using the best open-source models.

3
Download & share

Download, copy, or share your result. Free for personal and commercial use.

Use this tool via API

Automate this tool from your own code. OpenAI-compatible REST endpoint, Bearer-token auth, no extra SDK required. Token costs match the web interface.

curl -X POST https://api.free.ai/v1/chat/ \
  -H "Authorization: Bearer sk-free-..." \
  -H "Content-Type: application/json" \
  -d '{"model": "qwen-coder", "messages": [{"role": "user", "content": "Write a Python function that reverses a string."}]}'

Code Converter - FAQ

Paste code in one language, pick the target language, and get back the equivalent code idiomatic to the new language. Supports 16+ languages (Python ↔ JavaScript / TypeScript / Go / Rust / Java / C++ / C# / Ruby / PHP / Swift / Kotlin / Shell). Optionally preserve comments verbatim, force idiomatic adaptation (use the target language's patterns rather than literal translation), or keep the structure 1:1 for line-by-line review.

Facebook's TransCoder is research-grade and limited to C++/Java/Python. Codeporting charges per-line for legacy migrations (VB6→.NET etc.). ChatGPT does this well but costs $20/mo for the GPT-4 quality you'd want. Free.ai handles 16+ languages, runs on the daily free token pool, and the prompt explicitly toggles between literal-translation and idiomatic-rewrite modes.

Algorithm-heavy code (data structures, math, parsing) ports cleanly - usually 90%+ correct on first pass. Code that uses language-specific stdlib (Python's decorators, Go's goroutines, Rust's ownership) requires the model to find idiomatic equivalents - usually correct but always review. Code that depends on framework conventions (Django ORM → Rails ActiveRecord) needs human follow-up - Free.ai gets the structure right but specific API mismatches happen.

Python ↔ JavaScript (very mature). Python → Go (clean - both have stdlib for most things). JavaScript → TypeScript (just adds types). Java → Kotlin (excellent - Kotlin is designed for this). C → Rust (translates the algorithm; you'll restructure for ownership). Hardest: anything → Rust on first try (lifetime annotations sometimes need manual fixing); JavaScript → Java (paradigm mismatch on async).

Yes when the option is checked - comments are translated verbatim into the target language's comment syntax (// vs # vs --). When unchecked, the model regenerates comments idiomatic to the target language and may consolidate verbose multi-line comments.

Literal: Python `for i, x in enumerate(arr):` becomes JavaScript `for (let i = 0; i < arr.length; i++) { let x = arr[i]; ... }` - line-by-line. Idiomatic: it becomes `arr.forEach((x, i) => { ... })`. Pick literal when you want to compare side-by-side; pick idiomatic when you want shippable code in the target language.

Usually yes for self-contained snippets. For code that imports third-party libraries, the model picks the closest target-language equivalent (Python `requests` → JavaScript `fetch`, Java `Optional` → Rust `Option`) and notes any non-obvious substitutions. Always run the target-language compiler / linter after.

JSweet (Java→JS), Transcrypt (Python→JS), and Brython (Python in browser) are SOURCE-TO-SOURCE COMPILERS - they emit machine-translated, often verbose code and require runtime support. Free.ai writes IDIOMATIC code in the target language as a human would - reads naturally, no runtime, but requires review.

Yes - pick SQL as both source and target and the model uses the dialect picker on /code/sql/ (PostgreSQL ↔ MySQL ↔ SQLite ↔ MSSQL ↔ Oracle ↔ BigQuery). Use /code/sql/ for richer dialect-conversion features including schema-aware suggestions.

Up to 12,000 characters (~180 lines) on the self-hosted path. Premium long-context Claude/GPT handle 200K+ characters - switch for whole-file conversions.

Code is sent to the model, processed, and discarded. Not stored, not used for training. Pick Qwen 3 Coder for maximum privacy - self-hosted on Free.ai's GPUs.

Yes - POST to /v1/chat/ with the convert system prompt (source language + target language + idiomatic flag) and the code as the user message. See /api/ for snippets.

Sign up free: 30,000 tokens/day

Create Free Account

No credit card required

How would you rate this tool?

Love Free.ai? Tell your friends!