Composting directly in an urban planter box is possible, but it works best as a managed system rather than simply tossing scraps into the soil. A planter box is a small, enclosed space, so the margin for error is lower than in an open garden bed. You need enough volume, airflow, moisture balance, and a way to separate fresh kitchen waste from plant roots.
The safest approach is to use a dedicated corner or a buried container. Trench composting works if the planter has contact with the ground and enough soil depth: dig a small trench, add chopped fruit and vegetable scraps, cover with at least 8 to 10 inches of soil, and rotate spots. This keeps smells down and reduces pest attraction. In a closed planter on a balcony, a worm bin or a small bokashi system is usually more practical. You can sink a lidded worm tower into the planter, add worms and bedding, and let them process scraps while casting nutrients into the surrounding soil.
For direct composting, keep the carbon-to-nitrogen ratio balanced. Add browns such as shredded paper, cardboard, dry leaves, or coir with every addition of green scraps. Avoid meat, dairy, oils, pet waste, and diseased plants. Bury scraps deeply, cover them completely, and never let fresh waste sit on the surface. Keep the mix as moist as a wrung-out sponge and turn or aerate it occasionally. In hot weather, monitor for odor; in wet weather, prevent waterlogging.
Do not let uncomposted material touch plant roots directly. It can burn roots, attract rodents, or create anaerobic pockets. If the planter is shallow or already crowded with roots, compost in a separate small bin and add finished compost later. Also check local rules and building policies.
So yes, you can compost directly in an urban planter box, but use small batches, bury scraps, add browns, manage moisture, and consider a worm tower or bokashi if space is tight. Done carefully, it turns a city planter into a productive mini ecosystem.