Source: https://mokxi.com/errors/expected-at-end-of-input
Updated: 2026-11-16

Home / Errors
Arduino build error

# error: expected '}' at end of input

The file ended while a function or block was still open. There are more { than } in the sketch.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes
- Seen 2,761 times in failed builds on Mokxi in the 30 days to November 16, 2026.

The message

## What the Arduino IDE prints

Output window

The reported line is the last one. The missing brace is somewhere above, in the block that was never closed.

Mokxi's compiler, clang, words it as expected '}', with a note pointing at the brace that was never closed.

Causes

## The 2 usual causes with the fix

### 1A block was opened and not closed

Count the braces of the block you edited last. Each { needs its own }. When the next function then looks like it starts inside the open block, Mokxi says so.

Broken

Fixed

Mokxi’s build tab says: A function starts inside another one.

Try this fix in Mokxi

### 2A brace was deleted while editing

Cutting and pasting lines can take a closing brace with them. The last function is the one reported, though it is not the broken one.

Broken

Fixed

Mokxi’s build tab says: The { on line 6 is never closed.

Try this fix in Mokxi

FAQ

## Questions and answers

### What does "expected '}' at end of input" mean?

The sketch ended before every opened brace was closed. A closing brace is missing.

### How do I find which brace is missing?

Press Auto Format. The code after the missing brace is indented one level too far, which shows where the block should have closed.

### Can a missing brace in a library cause this?

Rarely. The error is almost always in your own sketch, and the file name in the message says which tab.

Next

## More errors and the longer guide

- error: expected unqualified-id before 'if'
- error: expected ';' before '}' token

The longer guide to this error All Arduino errors
