Transcranial direct current stimulation (tDCS) provides a non-invasive tool to elicit neuromodulation by delivering current through electrodes placed on the scalp. The present clinical paradigm uses two relatively large electrodes to inject current through the head resulting in electric fields that are broadly distributed over large regions of the brain. In this paper, we present a method that uses multiple small electrodes (i.e. 1.2 cm diameter) and systematically optimize the applied currents to achieve effective and targeted stimulation while ensuring safety of stimulation. We found a fundamental trade-off between achievable intensity (at the target) and focality, and algorithms to optimize both measures are presented. When compared with large pad-electrodes (approximated here by a set of small electrodes covering 25 cm(2)), the proposed approach achieves electric fields which exhibit simultaneously greater focality (80% improvement) and higher target intensity (98% improvement) at cortical targets using the same total current applied. These improvements illustrate the previously unrecognized and non-trivial dependence of the optimal electrode configuration on the desired electric field orientation and the maximum total current (due to safety). Similarly, by exploiting idiosyncratic details of brain anatomy, the optimization approach significantly improves upon prior un-optimized approaches using small electrodes. The analysis also reveals the optimal use of conventional bipolar montages: maximally intense tangential fields are attained with the two electrodes placed at a considerable distance from the target along the direction of the desired field; when radial fields are desired, the maximum-intensity configuration consists of an electrode placed directly over the target with a distant return electrode. To summarize, if a target location and stimulation orientation can be defined by the clinician, then the proposed technique is superior in terms of both focality and intensity as compared to previous solutions and is thus expected to translate into improved patient safety and increased clinical efficacy.