ChatGPT for coding and canvas
Canvas gives ChatGPT a side-by-side editor where code and writing live in a persistent document you revise in place, instead of scrolling through a chat thread chasing the last good version of a function. The chat stays on the left, the artifact stays on the right, and edits land surgically: rename a variable, refactor one block, add inline comments, without regenerating the whole file. This lesson shows you how to actually work in Canvas, when to reachreachThe number of unique people exposed to your message in a given period. Unlike impressions, reach counts each person once, no matter how often they see it.View full definition → for it versus Advanced Data Analysis or Codex, and how a non-developer can read along and stay in control.
What Canvas actually changes
In a normal chat, every revision is a new message. The model reprints the entire script, you copy it out, and you lose the diff. Canvas turns that artifact into a living document. Ask for a change and ChatGPT edits the existing text, highlighting what moved.
Canvas opens automatically when ChatGPT decides a response is substantial code or long-form writing, or you can force it by saying "open this in canvas." Inside the editor you get:
- Inline targeted edits. Select a few lines, describe a change, and only that region updates.
- Code-aware shortcuts. A menu offers actions like add comments, add logs, fix bugs, port to another language, and review code.
- Version history. Step back to an earlier state when an edit makes things worse.
The official overview lives in the ChatGPT Canvas help article. Read it once, then learn by building.
Build a small script in Canvas
Let us make something concrete and genuinely useful: a script that reads a CSV of expenses and prints a category summary. Even if you do not write Python, you can drive this and verify the output.
Start in any ChatGPT conversation:
Open a canvas. Write a Python script that readsexpenses.csvwith columnsdate,category,amount, sums the amount per category, and prints categories sorted from highest to lowest spend. Use only the standard library.
Canvas opens on the right with something like this:
import csv
from collections import defaultdict
def summarize(path: str) -> dict[str, float]:
totals: dict[str, float] = defaultdict(float)
with open(path, newline="") as f:
for row in csv.DictReader(f):
totals[row["category"]] += float(row["amount"])
return dict(totals)
if __name__ == "__main__":
totals = summarize("expenses.csv")
for category, amount in sorted(totals.items(), key=lambda kv: kv[1], reverse=True):
print(f"{category:<15} {amount:>10.2f}")Now you revise in place. This is the part that does not work cleanly in plain chat.
Edit one region, not the whole file
Select the print line inside the loop and tell Canvas:
Also show each category's share of total spend as a percentage.
Canvas rewrites only the printing logic and the surrounding lines it needs, leaving summarize untouched. You see the change highlighted. If you dislike it, version history rolls it back.
Use the built-in code actions
Open the Canvas shortcut menu and pick Add comments. ChatGPT annotates the functions without you writing a prompt. Pick Add logs and it inserts logging so you can trace what the script does at runtime. These are one-click because the model already knows the document is code.
The Fix bugs action is the one to understand well. Canvas scans the current document, proposes corrections, and explains each. It is not running the code, so it reasons about likely bugs rather than observed failures. That distinction matters, and it leads directly to the next tool.
Canvas vs advanced data analysis vs codex
These three overlap, and choosing wrong wastes time. Here is the clean split.
Canvas is an editor. It writes and revises code and prose, but it does not execute your Python against your data. It is where you shape an artifact you will run elsewhere.
Advanced Data Analysis (the feature formerly surfaced as Code Interpreter) runs Python in a sandbox. Upload your expenses.csv, and ChatGPT executes the script, shows real output, plots charts, and catches actual runtime errors. Use it when you need results from data, not just source code. See the Advanced Data Analysis help article.
Codex is OpenAI's software engineering agent. It works across a whole repository, runs in its own environment, executes tests, and can open pull requests. It is built for real codebases and multi-file tasks, not a single snippet. Details are in the Codex documentation.
A practical workflow chains them. Draft and refine the script in Canvas. Move to Advanced Data Analysis to run it on the real CSV and confirm the numbers. Graduate to Codex when the script becomes a project with tests, dependencies, and version control.
Introducing canvas
Making Canvas reliable
Canvas is only as good as the constraints you give it. A few habits keep it from drifting.
Pin your constraints early
State the non-negotiables in the first prompt: language version, allowed libraries, style, and target environment. "Use only the standard library" above prevented Canvas from reaching for pandas, which would have forced an install you did not want. If you skip this, expect dependencies to creep in on later edits.
Custom instructions and Projects carry context
If you always want type hints, docstrings in a specific format, or a particular error-handling style, put that in custom instructions so every Canvas session inherits it. For a sustained effort, work inside a Project: it keeps related chats, files, and instructions together, so the Canvas you open tomorrow remembers the conventions you set today.
Verify, do not trust
Canvas does not run code, so a script can look perfect and still fail. Two cheap defenses:
- Ask Canvas to add a tiny test or a sample input at the bottom, then move the file to Advanced Data Analysis and actually run it.
- Use Review code to get a critique, then read the critique yourself. The model will often flag its own edge cases: empty files, missing columns, non-numeric amounts.
For our script, a good follow-up edit is:
Handle a missing file and rows where amount is not a number. Skip bad rows and print how many were skipped.Canvas patches summarize and the entry point without disturbing the formatting logic you already approved.
Knowledge check
1. What is the fundamental difference between revising code in a normal chat thread versus in Canvas?
2. According to the lesson, how does Canvas open during a conversation?
3. Why is version history especially useful when working in Canvas?
4. Select ALL the capabilities that Canvas provides according to the lesson.
Select all the correct answers.
5. Select ALL statements that correctly describe how a non-developer can stay in control while building the expense-summary script in Canvas.
Select all the correct answers.
From Canvas to something runnable
A script in an editor is a draft. The path to production depends on what you are building.
For a personal, repeatable task
If this expense summary is something you want weekly, you are not limited to running it by hand. ChatGPT supports scheduled tasks, which can trigger a prompt on a recurring basis. You can ask ChatGPT to remind you to drop in the latest CSV and rerun the analysis, turning a one-off script into a routine.
For your own dataown dataData collected directly from your own customers and prospects through your own channels: your most reliable and privacy-compliant source.View full definition → sources
When the data does not live in a file you upload but in a connected system, Connectors let ChatGPT read from tools like cloud drives and select third-party apps, subject to your plan and admin settings. Instead of "read expenses.csv," the task becomes "summarize this month's expenses from the connected sheet." Canvas still drafts the logic; Connectors supply the live input.
For real software
Once the work outgrows a single file, hand it to Codex inside a repository, or rebuild the logic as a proper program against the OpenAI APIAPIApplication Programming Interface: a standardised interface that lets applications communicate and exchange data without knowing each other's internal workings.View full definition →. The same summarize function can sit behind a structured-output call so another system gets clean JSON instead of printed text:
from openai import OpenAI
from pydantic import BaseModel
client = OpenAI()
class CategorySummary(BaseModel):
category: str
total: float
share: float
class Report(BaseModel):
rows: list[CategorySummary]
skipped: int
resp = client.responses.parse(
model="gpt-5",
input="Summarize this expense data into per-category totals and shares.",
text_format=Report,
)
print(resp.output_parsed.rows[0].category)This uses the Responses API with structured outputs, so the model returns data that matches your schemaschemaA schema is the formal blueprint that defines how data is structured, named, typed, and related within a database, file, or message.View full definition → instead of free text you have to parse. Canvas is where you prototype the idea; the API is where it becomes a dependable component. The full reference is at platform.openai.com/docs.
Why this matters for non-developers
You do not have to write the loop to own the result. In Canvas you read the highlighted diffs, accept or reject them, and steer with plain English: "show percentages," "skip bad rows," "explain this function in one sentence." That feedback loop is the actual skill. The model handles syntax; you handle intent, constraints, and verification.
The trap is treating Canvas output as finished because it looks clean. Clean code can be wrong code. Your job is to keep restating constraints, run the script somewhere that executes it, and read the critiques the model gives you. Do that, and Canvas becomes a fast, controllable way to produce small tools you understand, even without a coding background.
Key Takeaways
- Use Canvas to revise in place. Select a region, describe the change, and only that part updates, with version history to undo. Stop regenerating whole files in chat.
- Pick the right tool: Canvas edits, Advanced Data Analysis executes against your data, Codex handles real repositories. Chain them: draft, run, then ship.
- Pin constraints up front (language, libraries, style) and push recurring conventions into custom instructions or a Project so every session inherits them.
- Never trust unrun code. Canvas does not execute; move the script to Advanced Data Analysis or add a test before relying on the output.
- Graduate to the API for production. Use the Responses API with structured outputs when the logic must become a dependable component other systems call.
Related articles
Recent articles from the blog that build on this lesson.
- AI$600M in annualized revenue on code nobody's engineering team wroteLovable just crossed $600M in annualized revenue, and the apps built on its platform are pulling nearly a billion monthly views. That number is worth pausing on, because it traces back to an idea about programming that most engineers spent years dismissing.
- AIVibe coding for non-engineers: the hype is real, but the risk is being misreadCoding assistants like GitHub Copilot, Cursor, and Claude have made it genuinely possible for non-engineers to build working software. But the dominant narrative around "vibe coding" is flattening a more complicated reality that professionals need to understand before betting on it.