Standard electrical wall mounting box specifications for the USA
sizeof(j_box)

Standard North American junction boxes come in a variety of shapes and sizes (round, octagon, square, rectangular); however, most wiring devices intended for junction box mounting, save for light fixtures, are designed around the standard device yoke mounting pattern -- this is defined in NEMA WD-6 (an abridged version can be found here) as a 4.1" by 1.1" metal strap with holes at each end, on the long axis centerline, 3.75" apart and equally spaced from the short axis of symmetry.  The device face itself is 2.78" by 1.625".

Each yoke (save for a rare few large receptacles that take up two gangs) mounts to a gang -- the space in a device box reserved for a single wiring device.  This is how rectangular boxes are measured -- by the number of gangs they accommodate.  Other shapes have a nominal dimension; for square boxes, this is the length of a side, while for octagons and rounds, this is the diameter of the box.

Square boxes (irrespective of size: the smallest square is 4", with 411/16" and a few 5" squares available for bigger jobs) can also be used for devices, using a mud ring or faceplate to adapt the box to the device.  Larger octagon boxes (4") can also mount devices to their faceplates; smaller octagon and all round boxes are reserved for light fixtures, though.

That's not all there is though

Even if two boxes are the same size, they may differ in other characteristics.  Metal boxes are designed for use with metal conduit or metal-sheathed cables, and thus have knockouts that can be removed to make way for conduit or cable to pass into them; non-metallic cables can be used with a metal box with a suitable cable clamp though.  Non-metallic boxes are typically used exclusively with non-metallic sheathed cables, and thus have built in cable clamps but no knockouts, although a few non-metallic boxes have knockouts as they are designed for use with non-metallic conduits instead of cables.

There are also various means of mounting boxes: surface boxes are designed to mount to the surface of a wall and stick out from it (say in an unfinished or industrial area), while new work boxes are designed to mount to wall studs and be flush with the finished wall, and old work boxes mount to the opening in the finish sheathing of the wall made for the box using integral clamps.

Special boxes for special jobs

Ceiling fans and heavy fixtures such as chandeliers are mounted to ceiling fan rated round or octagon boxes that securely anchor to the structure of the building, due to the weight and dynamic loads fans impose on their mountings.

There are also extension boxes that are used to add space to an existing box or protect the inside of material that is added to an existing wall, and larger NEMA enclosures for use in larger-scale (often industrial) applications where standard junction boxes are too tiny, or to mount parts that don't fit into a standard gang or to a standard knockout (such as industrial components that mount to DIN rail).