Home / Prompts / Life / Fix my code

Fix my code

Paste your code and the error message to get the cause, a fixed version and how to avoid it next time.

The prompt is put together in your browser. Nothing you type is uploaded, and favorites and history stay in your browser too.

Good for

  • A button on your web page does nothing when clicked
  • A Python script stops halfway with an error message
  • Code copied from the internet does not work on your machine

1. Fill in the details

2. Adjust the options

A filled-in example

Fill it in like this. Press the button below to put the example into the form above.

Language or tool
JavaScript
Code
const total = document.getElementById("total"); button.addEventListener("click", () => { total.textContent = price * qty; });
Error message
Uncaught ReferenceError: button is not defined
What it should do
Clicking the button should show the total price

What the AI's answer looks like

Illustrative excerpt: the real answer depends on the AI you use and what you fill in.

The cause: the code uses button but never looks the button up, so the browser does not know what button is.

Fixed code
```js
const total = document.getElementById("total");
const button = document.getElementById("calc"); // new: find the button first

button.addEventListener("click", () => {
  total.textContent = price * qty;
});
```

What changed: line 2 is new and finds the button by its id (make sure the button's id in your HTML is calc).

Next time: "is not defined" usually means a variable was never declared or its name is misspelled.

Tips

  • Paste the full error, line numbers included; "it is broken" is hard to diagnose
  • Remove API keys, passwords and other secrets before pasting code
  • Ask the AI to explain the fix so you can handle the same error yourself next time

How to use it

  1. Fill in the fields. You can leave a field empty for now; the prompt will show a [Please add] placeholder.
  2. Choose the tone, length and where you will paste it, then press Copy.
  3. Paste it into ChatGPT, Claude, Gemini, DeepSeek or a local model. If the AI asks you questions, answer them and the result gets better.

Related prompts

Single-file web app

No coding needed: describe the tool you want and get one HTML file that works when you open it.

Python automation script

Rename files in bulk, sort photos, merge spreadsheets... describe the chore and get a script that does it in one go.

Explain it simply

Get anything you do not understand explained with everyday examples, then a few questions to check you got it.

← Back to AI prompts for everyday life