This is a common and important concern for gardeners. The short answer is: it depends on the type of wood treatment used. Traditionally, woods like railroad ties or older pressure-treated lumber were preserved with chemicals containing arsenic, chromium, or copper, which could potentially leach into soil and be absorbed by plant roots. For edible gardens, these are best avoided.
However, modern pressure-treated woods for residential use often employ safer, copper-based preservatives. While the risk is significantly lower, some gardeners prefer maximum caution for food crops. The safest approach is to use naturally rot-resistant woods like cedar, redwood, or juniper. If using treated wood, line the interior of the planter box with a heavy-duty plastic barrier (like HDPE) to create a physical barrier between the soil and the wood. Ensure the liner has drainage holes.
For ultimate peace of mind, opt for untreated, naturally durable wood or alternative materials like stone, brick, or food-safe composite lumber. Your vegetables will thrive, and you'll enjoy your harvest without worry.