# Arduino “expected ‘;’ before” and “expected ‘}’ at end of input”

> Fix Arduino compile errors expected semicolon before, expected at end of input and stray characters: where the real mistake usually is.

Canonical: https://roboticsengineering.in/fix/arduino-expected-semicolon-before/ | Published: 2026-11-03 | Updated: 2026-11-03

**The compiler reports the line where it noticed the problem, which is often one line after the mistake.** Look at the line above the one it names.

## What the message means

A missing semicolon or brace is only noticed when the next token appears. So “expected ‘;’ before X” points at X, but the missing mark is just before it.

## Fix it in this order

1. Open the line named in the message, then read the line above it for a missing semicolon.
2. Count braces. Every opening brace needs a closing one. The IDE highlights the partner when you click next to a brace.
3. Use Tools > Auto Format. Odd indentation shows where a brace is missing.
4. Check that every statement inside a function ends in a semicolon and that a class or struct ends with }; .
5. Look for a stray character pasted from a web page, such as a curly quote.
6. Comment out code in halves until the error disappears, to find the block that causes it.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Error at the last line | A closing brace is missing somewhere above. |
| Error after a #define | Do not end a #define with a semicolon unless you need one. |
| Error after pasting code | Replace curly quotes with straight quotes. |

## Related

[was not declared in this scope](https://roboticsengineering.in/fix/arduino-was-not-declared-in-this-scope/), [Arduino IDE setup](https://roboticsengineering.in/arduino-ide-setup/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
