For most hobby, experimental and science project purposes, the best way is to use a "wall wart" transformer with DC output. Use appropriate resistors. For more details on determing what resistors to use, go to My LED Resistor Page.
Persons who are properly qualified and experienced at building line voltage powered electronic devices can:
a) Hack an LED night light.
B) Build a circuit to power an LED from line voltage, which would typically for low power LEDs (up to 30 mA) consist of:
* A brigde rectifier, with the LED connected to the DC output leads. The voltage rating of the bridge rectifier is not important.
* A capacitor in series with one of the AC leads of the bridge rectifier to limit the current. Use .47 microfarads to get approximately 19 milliamps of LED current (assuming 120 volts 60 Hz). The capacitor must have an actual AC voltage rating well above the line voltage. A DC rating well above 1.414 times the line voltage is not sufficient - an actual AC rating is required.
* A resistor in series with either AC lead of the bridge rectifier to limit peak current. If you have a capacitor across the LED (recommended around 220 microfarads), then this resistor only needs to be perhaps 33 to 100 ohms (for 120 volts AC). Otherwise this resistor needs to be at least 1.5 Kohms unless the LED is known to reliably repeatedly withstand current peaks well over 100 mA. This resistor should be a composition or wirewound type rather than a film type or otherwise known to reliably handle the current inrush through the current-limiting capacitor when power is applied.
* A fuse in case things go wrong.
* A resistor across either the current-limiting capacitor or the line terminals of this circuit, so that the line terminals do not present a shock hazard from charge of the current-limiting capacitor after this circuit is disconnected. The resistor needs to discharge the current-limiting capacitor from the peak line voltage (typically 169 volts) to no more than 28 volts (almost 2 time constants) within a fraction of a second. A 220K resistor discharges a .47 microfarad capacitor from 169 volts to 28 volts in about .19 second (max. of .23 second with 10% tolerances of resistor and capacitor) and will dissipate approx. .065 watt at 120 volts.