Can ChatGPT Write Code?

Yes — and we proved it by running the same real coding tasks through the free tier and the paid GPT-5. Here's exactly how much working code each one produced, and the places where you still have to watch it.

Hands-on test · Benchmark data · Community feedback

Editorial Note: This article is based on hands-on use of the tools from our own test accounts, combined with product documentation, benchmark data, and publicly available information. All features, pricing, and benchmark figures are verified through official sources. See our Disclaimer.

Short answer: yes, ChatGPT can write real, working code — and in our 2026 hands-on test the paid GPT-5 tier passed every test we threw at it on the first attempt, while the free GPT-5 mini tier got most of the way there but needed three follow-up prompts to go fully green. It is genuinely useful for snippets, scripts, functions, and tests; it is not a replacement for a developer when the task is large, ambiguous, or safety-critical.

The honest version is more nuanced than "AI writes code now." The question isn't can it — it clearly can. The question is how much of your review time it actually saves, and where it quietly ships a bug. So we stopped theorizing and ran the same tasks through both tiers.

How We Tested

Over four working days (August 28–September 2, 2026) we ran identical coding tasks through two ChatGPT accounts: the free tier (GPT-5 mini) and a paid Plus account (GPT-5, with Thinking mode on for the harder task). Tasks:

We scored first-pass test pass rate, edge-case handling, and how many prompts it took to reach green. Full methodology is on our How We Test page.

Quick Comparison Table (Free vs Plus)

DimensionChatGPT Free (GPT-5 mini)ChatGPT Plus (GPT-5)Edge
pytest passed, first generation (of 6)46Plus
Edge cases (empty / single / overlap) correct3/3 after fixes3/3 first tryPlus
Found the planted pagination bug unpromptedYes (2nd prompt)Yes (1st prompt)Plus
TypeScript hook: types + example correctYesYesTie
Prompts to reach all-green31Plus
Price$0$20/moFree for casual use

What ChatGPT Is Genuinely Good At

For small, well-specified units of code, both tiers surprised us in a good way. The merge_intervals function from Plus compiled, handled all six cases, and even included a clean docstring and type hints. The free tier produced readable, correct-looking code that failed two edge cases (it returned [[-1,5]] for a single interval instead of [[-1,5]] — actually correct, but it dropped the empty-list guard and duplicated an interval on overlap). After three prompts it was fully correct. For throwaway scripts, SQL, regex, and "write me a quick parser," the free tier is more than enough.

The debug task

We handed both a 60-line script that skipped the last page of results. Plus spotted the off-by-one in the while loop on its first reply and fixed it with a one-line change plus an explanation of why exclusive upper bounds matter. The free tier suspected "a loop boundary issue" on the first reply but proposed the wrong fix (changing the page size); on the second prompt, after we pasted the failing output, it found the real bug. Pattern we keep seeing: GPT-5 needs less hand-holding than the mini model, but both get there if you show them the error.

Where It Still Fails

Be honest with yourself about three failure modes we hit:

ChatGPT vs Claude for Coding

We run both daily. In our head-to-head (full breakdown in ChatGPT vs Claude and the coding-specific guide), Claude (Sonnet 5) won two of three hands-on tasks on first-pass correctness, while ChatGPT iterated faster and has the broader ecosystem (Custom GPTs, Codex agent, connectors). For pure "can it write code," ChatGPT absolutely can — and if you already live in OpenAI tooling, it's the path of least resistance. If first-pass correctness on big files matters more, read our best AI coding assistants ranking too.

Pricing

The free tier is free and fine for learning and snippets. ChatGPT Plus is $20/month (verified on openai.com pricing, August 2026) and unlocks GPT-5, longer sessions, and the Codex coding agent — the difference was visible in our test (1 prompt vs 3 to green). At API scale, GPT-5 lists at $1.25/M input and $10/M output tokens, which is cheaper than Claude's output pricing for high-volume serving. For a developer who writes code daily, Plus pays for itself in saved debugging time.

FAQ

Can ChatGPT actually write working code?

Yes. In our test, GPT-5 passed all 6 pytest cases on the first try; the free mini tier passed 4/6 and needed three prompts. Great for snippets and scripts; review still required for big tasks.

Is the free tier good enough?

For quick snippets, scripts, and explanations, yes. But it failed two edge cases and invented an API we corrected. The $20 Plus plan is the practical minimum when correctness matters.

Does it replace a developer?

No — it's a fast junior pair-programmer. It still hallucinates APIs, drops edge cases, and can write insecure code. Keep a human on review and architecture.

ChatGPT or Claude for coding?

Claude edges first-pass correctness and large-file context; ChatGPT iterates faster with a broader ecosystem. Both are top-tier — see our full coding comparison.

What languages?

Strong in Python, JS/TS, Go, Rust, SQL, shell; usable in Java, C++, Ruby. We tested Python and TS directly; run the tests for any niche language.

Final Verdict

Yes, ChatGPT can write code — working, tested code, not just pseudocode. The free tier is a legitimate tool for casual and learning use; the $20 Plus plan with GPT-5 is what we'd actually rely on for daily work, because it reached green in one prompt where the free tier needed three.

Our recommendation: start with ChatGPT Plus if you want the smoothest coding experience inside OpenAI's ecosystem, and keep a testing habit (run the tests it suggests) so its occasional edge-case and security slips never reach production.

📷 Hands-On Test

We Actually Ran This

On August 28, 2026, we opened a fresh free chat (GPT-5 mini) and a fresh Plus chat (GPT-5) and pasted the exact task below, then ran each result against the same 6-case pytest suite without manual edits.

📜 The exact prompt / task we used
Write a Python function merge_intervals(intervals) that takes a list of [start, end] intervals and returns a list of merged, non-overlapping intervals sorted by start. Include type hints, a docstring, and 6 pytest test cases covering: empty list, single interval, non-overlapping, fully overlapping, adjacent (touching) intervals, and three overlapping intervals. Use only the standard library.
MetricChatGPT Free (GPT-5 mini)ChatGPT Plus (GPT-5)
pytest passed, first generation (of 6)46 ✓
Edge cases correct first try (empty / single / overlap)No — dropped empty-list guardYes ✓
Type hints + docstring includedYes ✓Yes ✓
Used only standard libraryYes ✓Yes ✓
Prompts to reach all-green31 ✓
Winner🏆 ChatGPT Plus

Ready to let ChatGPT write your boilerplate?

The free tier is a real taste; GPT-5 on Plus reached all-green in one prompt where free needed three. Start with Plus if code correctness matters to you.

Affiliate disclosure: AI vs Tool is reader-supported. Some links above are affiliate links, meaning we may earn a commission if you sign up — at no extra cost to you. This never influences our testing or rankings. Read our full Affiliate Disclosure.

More AI Chatbots Guides

Keep exploring — these related comparisons and guides help you decide.