Two-by-four beams are sturdy enough to hold up your house. After all, most of your walls are built on a frame of 2X4 beams. In general, shelves made of other materials are ultimately anchored in the 2X4 beams in your wall. Building wall brackets out of 2X4s is one way to make certain that your shelf has sufficient support for any load somebody could reasonably lift up onto it.
Cut the beams into 1-foot long sections with a power saw. You will need three sections for each brace. If your shelves are significantly deeper than 1 foot, cut one of the three sections to match the depth of your shelves.
Set two beams perpendicular to each other, with the 2-inch side of one beam abutting the 4-inch face of the other. The outside edges of both beams should be flush with one another, as should both ends of each beam. If using one section of different length, neither of these beams should be the off-length beam.
Screw the beams together with three evenly spaced wood screws, driven through the outer 4-inch face of one beam and into the 2-inch edge of the other.
Lay the remaining beam down on the "L" formed by the two connected beams, with its 4-inch face resting on the ends of the other beams. The back end of this beam should be flush with the edges of the other beams.
Screw the beam in position with two wood screws, driven through the face of this beam into the ends of the other two beams.