Frequently asked questions

Video demonstration of how to use this site
(2.34 MB Shockwave Flash Movie)
Note: The entire video must download before you can view it. Depending on the speed of your Internet connection, this could take 15 seconds to 10 minutes. The video will open in a new window, so you can simply close that window after watching the movie. Popcorn not included.

To view an answer that is not yet open, click the box containing the question. You may need to scroll down if the entire answer is not visible. You can use the scroll bar on the right of each mini-window, but it's easier to use the scroll wheel on your mouse.

How do I use this site?

This utility allows you to visually check that your code's braces (a.k.a., curly braces), parentheses, brackets, and tags are balanced. It also makes it easy to see what braces open and close a given section of code. For example:

Demonstration of how to visually balance braces in your code

Similarly,

  • The opening brace that is highlighted yellow is closed by the closing brace highlighted yellow.
  • The opening brace that is highlighted gray is closed by the closing brace highlighted gray.
  • The opening brace that is highlighted tan is closed by the closing brace highlighted tan.
  • The opening brace that is highlighted green is closed by the closing brace highlighted green.

Note that nesting is also visually apparent. The braces highlighted magenta enclose all of the code nested between them. Similarly, the braces highlighted yellow enclose all of the code nested between them. This utility will correctly "decipher" code, no matter how many levels of nesting are present. The only exception is if you have braces in string, or character literals, such as $pattern = '}'. In such cases, just delete those braces after pasting your code into the box below. Alternatively, insert a matching brace in a comment (shaded red below) while writing your code:

{
$example = '{' // }
}

For simplicity, the following diagram shows braces without other code:

Balancing braces is easy when the various code sections are highlighted in different colors

In the top row, note that each brace is closed by the one immediately following it. The bottom row shows a more complex pattern of nested braces, as often appears in computer code. Programmers can now easily see if the braces are balanced, and what braces open and close various code blocks. This utility can also identify matching braces within nested RTF (Rich Text Format) groups.

The next diagram illustrates the appearance of code when its braces are balanced and unbalanced:

The appearance of code when its braces are balanced and unbalanced

If my braces are not balanced, how do I determine how many I must add?

Here is an example. Let's say that you're checking the following sample code:

Balancing braces example

As you can see, the beginning opening brace { is not closed by a corresponding closing brace shaded }. In fact, the yellow highlighting spills onto the end of the PHP script.

So how many braces are needed? It's easy to determine this by counting the number of colors of highlighted code that are not yet closed. In this case, the beginning { and { braces are not closed. The code shaded magenta between those two colors is ignored because it is balanced by an opening brace { and a closing brace }. Therefore, we add two braces to the original code, resubmit it, and get this:

Balancing braces example 2

Now we see that the initial opening brace { is closed } just before the script ends, as it should be. The preceding code highlighted yellow is also closed by its closing brace }.

Is there any charge for using this site?

No. It is free to use. There are no strings attached, no spyware, viruses, or other malicious code. Of course, I hope that you will read one of my books (the sidebar shows some that are free). I have tips that any man or woman would love to know, and books of ER stories that have attracted the attention of celebrities, an Emmy-award-winning Hollywood producer, and countless readers worldwide. My health and sex books aren't the usual "put you to sleep" stuff. If you care about your brain, bod, mood, happiness, and how appealing you are to the opposite sex, you must read my books because I present information that you won't get from other authors. And I guarantee it!

What else is this site useful for?

It is also great for verifying that you closed all of the parentheses ( ) and brackets [ ] in text such as term papers, book manuscripts, and articles. If you have more than a few words in them, it is easy to omit the closing parenthesis or bracket. To check your text, just paste it in, and select what you want to check.

Even though I am a perfectionist, I occasionally read something I wrote years ago and discover that I did not close a parenthesis. (Oops!