How to Use Square Brackets in Writing and Code

Square brackets are small. They look like this: [ ]. You see them a lot. In writing and in code. But they do different jobs in each place.

What square brackets do

First, they group or clarify stuff. In writing, they add information without changing the original quote. In code, they often pick out items or set up lists. So this means they help make meaning clearer. They also keep things neat.

Quick example

In a quote you might add a word for clarity. The bracket shows you added it. In code you might use them to access an item by number. They show you exactly which piece you mean.

Using brackets in writing

Writers use them to fix or explain quotes. If a quote is missing a word, you add it in brackets. If you want to show a mistake, you write [sic]. It tells the reader the odd part was in the original. You can also use brackets to add short notes inside parentheses. They keep things tidy.

Examples

Original quote: “She said she would arrive soon.”

With a fix: “She [the mayor] said she would arrive soon.”

It makes clear who “she” is. The reader gets extra context.

Using brackets in code

In programming, they do a few key jobs. They can pick an item from a list. They can wrap an array or an index. In some languages they mark optional parts. In others they group things for functions or dictionaries. You learn the exact use by the language. But the idea is the same. They point to a specific spot.

Examples

Array access: items[0] gets the first thing. In JSON, they start a list: [1, 2, 3]. In regex, they match any character inside them. So they are flexible.

Common mistakes to avoid

Don’t mix them with parentheses when the meaning changes. Don’t add too many brackets inside each other. That gets confusing. In quotes, don’t alter the original meaning. Use them only for small clarifications.

Quick tips

If you introduce a bracketed term, use it again with a pronoun after. That keeps sentences shorter and easier to read. Keep each bracketed note short. If you need a long explanation, use a footnote or a new sentence. Read your sentence out loud. If it sounds clunky, fix the bracket use.

Final thought

Brackets are simple tools. They add clarity. They tidy up code and quotes. Use them with care. Then they will make your writing and your code easier to understand.

Scroll to Top