Skip to content

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

Up to 1,500 characters.

Try an example:

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.

Count words

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 }`.
Totals from a CSV

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 helper

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.

Each model's results on the tool's test inputs
ModelPassedHard onesMessages used on ProCost per runTime per run
GPT-6 LunaOpenAI5 of 52 of 21 each, of 60 a day on Pro$0.000114.2 s
Claude Haiku 5.5Anthropic5 of 52 of 21 each, of 60 a day on Pro$0.00032.9 s
DeepSeek V4.1 FlashDeepSeek5 of 52 of 21 each, of 60 a day on Pro$0.00081.8 s
Gemini 3.8 FlashGoogle5 of 52 of 21 each, of 250 a month on Pro$0.00063.2 s
GLM 5.3Z.ai5 of 52 of 21 each, of 250 a month on Pro$0.00112.4 s
GPT-6.1 TerraOpenAI5 of 52 of 21 each, of 250 a month on Pro$0.00198.1 s
Claude Haiku 4.5Anthropic5 of 52 of 21 each, of 250 a month on Pro$0.00202.7 s
Mistral Large 4Mistral5 of 52 of 21 each, of 250 a month on Pro$0.003227.3 s
Grok 4.7xAI5 of 52 of 21 each, of 250 a month on Pro$0.009617.1 s
GPT-6.1 SolOpenAI5 of 52 of 21 each, of 125 a month on Pro$0.002410.8 s
GPT-6 SolOpenAI5 of 52 of 21 each, of 125 a month on Pro$0.00255.7 s
GPT-6.2 SolOpenAI5 of 52 of 21 each, of 125 a month on Pro$0.00354.3 s
Kimi K3Moonshot5 of 52 of 21 each, of 125 a month on Pro$0.00433.5 s
Claude Sonnet 5Anthropic5 of 52 of 21 each, of 125 a month on Pro$0.00504.2 s
Gemini 4 HydrogenGoogle5 of 52 of 21 each, of 125 a month on Pro$0.00517.1 s
Claude Sonnet 5.5Anthropic5 of 52 of 21 each, of 125 a month on Pro$0.00543.4 s
Kimi K3.1 ProMoonshot5 of 52 of 21 each, of 125 a month on Pro$0.006010.0 s
Gemini 3.1 Pro (preview)Google5 of 52 of 21 each, of 125 a month on Pro$0.00789.8 s
Gemini 4 ArgonGoogle5 of 52 of 21 each, of 62 a month on Pro$0.00208.7 s
Gemini 4 CarbonGoogle5 of 52 of 21 each, of 62 a month on Pro$0.00307.4 s
Claude Opus 5.5Anthropic5 of 52 of 21 each, of 62 a month on Pro$0.02028.2 s
GPT-6 AstraOpenAI5 of 52 of 21 each, of 31 a month on Pro$0.01106.1 s
GPT-6.2 AstraOpenAI5 of 52 of 21 each, of 31 a month on Pro$0.01235.1 s
Claude Fable 5.1Anthropic5 of 52 of 21 each, of 31 a month on Pro$0.02635.4 s
Claude Fable 5.2Anthropic5 of 52 of 21 each, of 31 a month on Pro$0.03097.1 s
GLM 5.3 FlashZ.ai4 of 52 of 21 each, of 60 a day on Pro$0.00015.4 s
DeepSeek V4 ProDeepSeek4 of 51 of 21 each, of 250 a month on Pro$0.011017.2 s
Passed: of the 5 test inputs, how many answers passed their check (an answer the provider failed to give isn't counted). Messages used: what each run counted as on Pro, and Pro's count on the model. Cost: what OpenRouter charged us per run, on average; in llmwise you pay per message, not per token. Time: from sending to the whole answer.

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".
GPT-6 Luna
```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.
Claude Haiku 5.5
```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

  1. Describe the function: its name, what goes in, what comes out, and an example. Up to 1,500 characters.

  2. Pick the language.

  3. Press “Write the code”. It runs on your plan (Plus or Pro) on the model you pick, and the whole answer streams in.

  4. 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.