AI tool · Code
AI code generator
Describe a function and get working code in JavaScript, Python, TypeScript, Java, Go or C#, with an example call, on any of 27 models. We ran every model's code against tests to see whose works.
Runs on Plus and Pro, on the model you pick
By running it, you agree to the Terms and Privacy Policy and confirm you’re 18 or older. We keep what you send and its answer for 7 days, or in your account if you sign up.
Test runs checked .
AI code generator: three examples
Three inputs and the code GPT-6 Luna gave each, made once on September 28, 2026 and shown as it came back. The example buttons in the box above show the same.
A function wordFrequencies(text) that returns an object mapping each lowercase word to how many times it appears, ignoring punctuation.
```javascript
function wordFrequencies(text) {
const frequencies = Object.create(null);
const words = String(text).toLowerCase().match(/[\p{L}\p{N}]+/gu) || [];
for (const word of words) {
frequencies[word] = (frequencies[word] || 0) + 1;
}
return frequencies;
}
```
It counts lowercase sequences of letters and numbers, ignoring punctuation; empty input returns an empty object.
Example: `wordFrequencies("Hello, hello!")` returns `{ hello: 2 }`.A function that reads a CSV file of orders (date, customer, amount) and returns the total amount per customer, highest first.
```python
import csv
from collections import defaultdict
from decimal import Decimal, InvalidOperation
from pathlib import Path
def total_amount_per_customer(csv_path: str | Path) -> list[tuple[str, Decimal]]:
"""Return (customer, total) pairs, sorted by total descending."""
totals: dict[str, Decimal] = defaultdict(Decimal)
with open(csv_path, "r", newline="", encoding="utf-8-sig") as file:
reader = csv.DictReader(file)
required = {"date", "customer", "amount"}
if reader.fieldnames is None or not required.issubset(reader.fieldnames):
raise ValueError("CSV must contain date, customer, and amount columns")
for row in reader:
customer = (row.get("customer") or "").strip()
raw_amount = (row.get("amount") or "").strip()
if not customer or not raw_amount:
continue
try:
totals[customer] += Decimal(raw_amount)
except InvalidOperation as exc:
raise ValueError(f"Invalid amount: {raw_amount!r}") from exc
return sorted(totals.items(), key=lambda item: (-item[1], item[0]))
```
It reads the named CSV columns, skips rows with a blank customer or amount, and sorts totals highest first (customer name breaks ties).
Example: `total_amount_per_customer("orders.csv")` returns entries such as `[("Ada", Decimal("25.50"))]`.A debounce(fn, ms) function: calls fn only after ms milliseconds have passed without another call, with the latest arguments.
```typescript
function debounce<T extends (...args: any[]) => void>(
fn: T,
ms: number
): (...args: Parameters<T>) => void {
let timer: ReturnType<typeof setTimeout> | undefined;
return (...args: Parameters<T>): void => {
if (timer !== undefined) clearTimeout(timer);
timer = setTimeout(() => fn(...args), Math.max(0, ms));
};
}
// Example:
const debouncedLog = debounce((message: string) => console.log(message), 300);
debouncedLog("first");
debouncedLog("latest"); // Calls fn with "latest" after 300 ms without another call.
```
Each call resets the timer, so `fn` runs with the latest arguments only after calls stop for `ms` milliseconds.Which AI model is best at this? We tested every one
In our test runs of 5 AI code generator inputs on 27 models, GPT-6 Luna, Claude Haiku 5.5, DeepSeek V4.1 Flash and 22 more passed the most: 5 of 5. That includes Claude Haiku 5.5 (an everyday model on every plan).
Run on November 19, 2026: 5 inputs on 27 models, each with this tool's own instructions.
| Model | Passed | Hard ones | Messages used on Pro | Cost per run | Time per run |
|---|---|---|---|---|---|
| GPT-6 LunaOpenAI | 5 of 5 | 2 of 2 | 1 each, of 60 a day on Pro | $0.0001 | 14.2 s |
| Claude Haiku 5.5Anthropic | 5 of 5 | 2 of 2 | 1 each, of 60 a day on Pro | $0.0003 | 2.9 s |
| DeepSeek V4.1 FlashDeepSeek | 5 of 5 | 2 of 2 | 1 each, of 60 a day on Pro | $0.0008 | 1.8 s |
| Gemini 3.8 FlashGoogle | 5 of 5 | 2 of 2 | 1 each, of 250 a month on Pro | $0.0006 | 3.2 s |
| GLM 5.3Z.ai | 5 of 5 | 2 of 2 | 1 each, of 250 a month on Pro | $0.0011 | 2.4 s |
| GPT-6.1 TerraOpenAI | 5 of 5 | 2 of 2 | 1 each, of 250 a month on Pro | $0.0019 | 8.1 s |
| Claude Haiku 4.5Anthropic | 5 of 5 | 2 of 2 | 1 each, of 250 a month on Pro | $0.0020 | 2.7 s |
| Mistral Large 4Mistral | 5 of 5 | 2 of 2 | 1 each, of 250 a month on Pro | $0.0032 | 27.3 s |
| Grok 4.7xAI | 5 of 5 | 2 of 2 | 1 each, of 250 a month on Pro | $0.0096 | 17.1 s |
| GPT-6.1 SolOpenAI | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0024 | 10.8 s |
| GPT-6 SolOpenAI | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0025 | 5.7 s |
| GPT-6.2 SolOpenAI | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0035 | 4.3 s |
| Kimi K3Moonshot | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0043 | 3.5 s |
| Claude Sonnet 5Anthropic | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0050 | 4.2 s |
| Gemini 4 HydrogenGoogle | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0051 | 7.1 s |
| Claude Sonnet 5.5Anthropic | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0054 | 3.4 s |
| Kimi K3.1 ProMoonshot | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0060 | 10.0 s |
| Gemini 3.1 Pro (preview)Google | 5 of 5 | 2 of 2 | 1 each, of 125 a month on Pro | $0.0078 | 9.8 s |
| Gemini 4 ArgonGoogle | 5 of 5 | 2 of 2 | 1 each, of 62 a month on Pro | $0.0020 | 8.7 s |
| Gemini 4 CarbonGoogle | 5 of 5 | 2 of 2 | 1 each, of 62 a month on Pro | $0.0030 | 7.4 s |
| Claude Opus 5.5Anthropic | 5 of 5 | 2 of 2 | 1 each, of 62 a month on Pro | $0.0202 | 8.2 s |
| GPT-6 AstraOpenAI | 5 of 5 | 2 of 2 | 1 each, of 31 a month on Pro | $0.0110 | 6.1 s |
| GPT-6.2 AstraOpenAI | 5 of 5 | 2 of 2 | 1 each, of 31 a month on Pro | $0.0123 | 5.1 s |
| Claude Fable 5.1Anthropic | 5 of 5 | 2 of 2 | 1 each, of 31 a month on Pro | $0.0263 | 5.4 s |
| Claude Fable 5.2Anthropic | 5 of 5 | 2 of 2 | 1 each, of 31 a month on Pro | $0.0309 | 7.1 s |
| GLM 5.3 FlashZ.ai | 4 of 5 | 2 of 2 | 1 each, of 60 a day on Pro | $0.0001 | 5.4 s |
| DeepSeek V4 ProDeepSeek | 4 of 5 | 1 of 2 | 1 each, of 250 a month on Pro | $0.0110 | 17.2 s |
Side by side: roman numerals, with invalid input rejected
The same input on GPT-6 Luna and Claude Haiku 5.5, as each answered it, unedited.
Write this code in one code block, complete and runnable, with the function name and arguments I give. Then at most three lines on how it works and an example call. --- A function romanToInt(s) that converts a Roman numeral (I, V, X, L, C, D, M, with the subtractive forms IV, IX, XL, XC, CD and CM) to an integer, and throws an error for anything that isn't a valid, standard numeral, such as "IIII", "VX" or "ABC".
```javascript
function romanToInt(s) {
if (typeof s !== "string" || !/^(?=.)M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/.test(s)) {
throw new Error("Invalid Roman numeral");
}
const values = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 };
let total = 0;
for (let i = 0; i < s.length; i++) {
const current = values[s[i]];
const next = values[s[i + 1]] || 0;
total += current < next ? -current : current;
}
return total;
}
romanToInt("MCMXCIV"); // 1994
```
The function validates standard canonical numerals from I through MMMCMXCIX, then converts them using subtractive notation. Invalid input throws an error.```javascript
function romanToInt(s) {
if (typeof s !== 'string' || s.length === 0) {
throw new Error('Input must be a non-empty string');
}
// Standard (canonical) Roman numerals, 1 to 3999
const pattern = /^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/;
if (!pattern.test(s)) {
throw new Error(`Invalid Roman numeral: "${s}"`);
}
const values = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 };
let total = 0;
for (let i = 0; i < s.length; i++) {
const current = values[s[i]];
const next = values[s[i + 1]] || 0;
total += current < next ? -current : current;
}
return total;
}
```
The regex accepts only standard forms, so "IIII", "VX" and "ABC" are rejected before any summing happens. The sum adds each symbol's value, subtracting it when a larger symbol follows. Empty or non-string input throws too.
Example: `romanToInt("MCMXCIV")` returns `1994`.How the inputs are scored
- Tests: the reply's JavaScript runs in a locked-down sandbox against our tests, edge cases included; it passes only if every test does.
The inputs: a palindrome check, split an array into chunks, human-readable file sizes, roman numerals, with invalid input rejected, and the next business day. Every model gets the tool's own instructions and up to Pro's reply limit. The method is the same as our other test runs.
How to use the AI code generator
Describe the function: its name, what goes in, what comes out, and an example. Up to 1,500 characters.
Pick the language.
Press “Write the code”. It runs on your plan (Plus or Pro) on the model you pick, and the whole answer streams in.
Run it on your example and your edge cases before you use it.
Tips for a better answer
Give it the signature
Name the function and its arguments (“parseDuration(text) returns seconds”). The code then drops straight into yours.
Show an example
One example in, one out (“parseDuration('1h 30m') returns 5400”) settles more than a paragraph of description.
Decide the edge cases
Say what should happen on bad input: throw, return null, or ignore it. Otherwise the code guesses.
Ask for tests too
Ask the same model for tests next, in the same chat. Tests written from the description catch what the code missed.
What a good code looks like
It runs on your edge cases
Run it before you trust it: on the example in your description, then on an empty input, a very long one and one with odd characters. That's where generated code breaks.
The signature you asked for
The function should have the name and the arguments you asked for, and return what you said, not print it. A different signature means rewiring your code around it.
No imaginary libraries
Generated code sometimes calls a library you don't have, or a function that doesn't exist in your version. Check every import, and ask for the standard library only if you need that.
Code you can read
Short and readable beats clever. If you can't follow it in one read, ask for a simpler version with comments; you'll be the one maintaining it.
What you need to run it, and what a run gives
Running it takes a plan, Plus or Pro. There's no free plan or trial: a plan is paid at checkout and renews every month until you cancel. Cancel in two clicks in Settings → Billing and you keep your plan to the end of the month you paid for. llmwise accounts are for people 18 and older.
Paste up to 20,000 characters in a run. It runs on the model you pick, shows the whole answer, and you can carry on in the chat with any model your plan has, or ask another model the same thing.
A run counts on your plan like any other message: the table above shows what one counted as on Pro, model by model.
More AI tools are on the tools page, and what each plan gives is on pricing.
Questions
Is the AI code generator free?
No: there's no free plan or trial. It runs on Plus and Pro, on any model your plan has; Claude Fable 5.2, GPT-6.2 Astra, and their earlier versions need Pro. Paid monthly from the day you start. Cancel in two clicks in Settings → Billing.
Which languages does it write?
JavaScript, TypeScript, Python, Java, Go and C#. Pick one; for anything else, name the language in your description.
Does the code actually work?
Our test runs below gave every model the same five functions to write in JavaScript and ran each one against tests in a sandbox: a model passed only if every test did. Your own code still needs testing.
Can it work with my existing code?
Yes: paste up to 20,000 characters of your own code and ask for a change, a fix or tests for it, on any of 27 models.
Is generated code safe to use?
You're responsible for what you ship. Read it, test it, and don't paste secrets (keys, passwords, customer data) into any AI tool.
Which AI is best for this, in your tests?
In our test runs of 5 AI code generator inputs on 27 models, GPT-6 Luna, Claude Haiku 5.5, DeepSeek V4.1 Flash and 22 more passed the most: 5 of 5. That includes Claude Haiku 5.5 (an everyday model on every plan). The table on this page has every model's result, what a run counts as on Pro, and the time it took.
Claude, GPT, Gemini, DeepSeek, Grok, Kimi, GLM, and Mistral, in one chat.
See what a message costs before you send it. Every plan is month to month: cancel in two clicks. Sign in with an email link, no password.