Skip to content

Free tool · Code

AI code generator

Describe a function and get working code in JavaScript, Python, TypeScript, Java, Go or C#, with an example call: 1 free run a day on GPT-6 Luna, no account needed. We ran every model's code against tests to see whose works.

1 free run a day, no account needed

GPT-6 Luna

Up to 1,500 characters. No files, tools or web search in a free run. One free run a browser, and one a network each day, shared with the free message on our home page.

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

AI code generator: three examples

Three inputs and the code a free run gave each, made once on September 28, 2026 with GPT-6 Luna 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

Every one of the 19 models we ran passed all 5 of our AI code generator test inputs, so choose on speed and price: GLM 5.3 was quickest, at 1.1 s a run on average. GPT-6 Luna, the model a free run is on, took 7.0 s.

Run on October 9, 2026: 5 inputs on 19 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 LunaOpenAIThe free run's model5 of 52 of 21 each, of 60 a day on Pro$0.00017.0 s
GLM 5.3 FlashZ.ai5 of 52 of 21 each, of 60 a day on Pro$0.00022.0 s
Claude Haiku 5.5Anthropic5 of 52 of 21 each, of 60 a day on Pro$0.00043.3 s
DeepSeek V4.1 FlashDeepSeek5 of 52 of 21 each, of 60 a day on Pro$0.00102.6 s
Gemini 3.8 FlashGoogle5 of 52 of 21 each, of 250 a month on Pro$0.00061.9 s
GLM 5.3Z.ai5 of 52 of 21 each, of 250 a month on Pro$0.00131.1 s
Claude Haiku 4.5Anthropic5 of 52 of 21 each, of 250 a month on Pro$0.00182.6 s
DeepSeek V4 ProDeepSeek5 of 52 of 21 each, of 250 a month on Pro$0.00476.1 s
Mistral Large 4Mistral5 of 52 of 21 each, of 250 a month on Pro$0.007034.2 s
Grok 4.7xAI5 of 52 of 21 each, of 250 a month on Pro$0.009119.5 s
GPT-6.1 SolOpenAI5 of 52 of 21 each, of 125 a month on Pro$0.00235.0 s
GPT-6 SolOpenAI5 of 52 of 21 each, of 125 a month on Pro$0.00274.9 s
Kimi K3Moonshot5 of 52 of 21 each, of 125 a month on Pro$0.002818.9 s
Claude Sonnet 5Anthropic5 of 52 of 21 each, of 125 a month on Pro$0.00504.0 s
Claude Sonnet 5.5Anthropic5 of 52 of 21 each, of 125 a month on Pro$0.00533.2 s
Gemini 3.1 Pro (preview)Google5 of 52 of 21 each, of 125 a month on Pro$0.007610.0 s
Claude Opus 5.5Anthropic5 of 52 of 21 each, of 62 a month on Pro$0.01747.3 s
GPT-6 AstraOpenAI5 of 52 of 21 each, of 31 a month on Pro$0.011728.5 s
Claude Fable 5.1Anthropic5 of 52 of 21 each, of 31 a month on Pro$0.02675.3 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 GLM 5.3 Flash, 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" || !/^(?=[MDCLXVI])[MDCLXVI]+$/.test(s)) {
    throw new Error("Invalid Roman numeral");
  }

  const values = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 };
  const standardForm =
    /^(M{0,3})(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/;

  if (!standardForm.test(s)) {
    throw new Error("Invalid Roman numeral");
  }

  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 function validates the numeral against standard Roman numeral notation (1–3999), then converts it.
Example: `romanToInt("MCMXCIV")` returns `1994`.
GLM 5.3 Flash
```javascript
function romanToInt(s) {
  if (typeof s !== "string" || s.length === 0) {
    throw new Error("Invalid Roman numeral: input must be a non-empty string");
  }
  if (!/^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: "${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 v = values[s[i]];
    const next = i + 1 < s.length ? values[s[i + 1]] : 0;
    total += v < next ? -v : v;
  }
  return total;
}
```
A regex enforces the canonical standard form (so "IIII", "VX", "ABC", and non-minimal forms are rejected), then the string is scanned left to right, subtracting a value when a smaller symbol precedes a larger one.
Example: romanToInt("MCMXCIV") returns 1994; romanToInt("VX") throws an Error.

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”. Without an account you see the start (1 free run a day, no account needed).

  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

    Signed in, 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's free, and what signing up adds

  • Without an account: 1 free run a day, on GPT-6 Luna, shared with the free message on our home page. It takes up to 1,500 characters, writes up to about 600 tokens (roughly 450 words), and shows you the start of the code.

  • Signing up is free, with an email link and no card. llmwise accounts are for people 18 and older. The code you ran comes with you as your first chat, and you get 5 free messages on almost every model (all but Claude Fable 5.1 and GPT-6 Astra).

  • Signed in, paste up to 20,000 characters in a run. It runs on the model you pick, on your plan, shows the whole answer, and you can carry on in the chat with any model.

More free tools are on the tools page, and what each plan gives is on pricing.

Questions

Is the AI code generator free?

Yes. Without an account you get 1 run a day on GPT-6 Luna, shared with the free message on our home page: you see the start of the answer, and the rest when you sign up. Signing up is free and adds 5 free messages on almost every model in llmwise (all but Claude Fable 5.1 and GPT-6 Astra; one of them can be on Claude Opus 5.5), with no card.

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?

Signed in, paste up to 20,000 characters of your own code and ask for a change, a fix or tests for it, on any of 19 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?

Every one of the 19 models we ran passed all 5 of our AI code generator test inputs, so choose on speed and price: GLM 5.3 was quickest, at 1.1 s a run on average. GPT-6 Luna, the model a free run is on, took 7.0 s. 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. Free is 5 messages to try; sign in with an email link, no password or card.