How do I wire an electrical outlet?
While wiring an outlet can be a fairly simple task when following all safety precautions, if you are unsure about anything or have a complicated scenario, it is best to consult a licensed electrician that understands local electrical code and laws. 

Tools and Materials Needed:

Outlet, of appropriate amperage 
Electrical box - (Old-work type for adding an outlet to your home) 
Non-metallic (NM) cable (also known as Romex) of appropriate gauge and length
Wire connectors (twist type or lever-nut type) 
Non-Contact Voltage Detector
Wire stripper
Screwdriver

Steps If you are installing new outlet: 

1. Turn off the power to the circuit you'll be working on by turning off the breaker 
2. Locate a nearby junction box, and confirm there is no power running to it with the non-contact voltage detector. 
3. Once deemed safe,  remove the cover plate.
4. Run a new length of Romex cable from the junction box to the location of the new outlet. You may need to drill holes through studs, floors, or even cut holes in the wall to achieve this. 
5. If the old outlet has connection screws that are not used, you may attach the new wire to the old outlet to run power to the new outlet. These are usually labeled “load” on the outlet.  Otherwise, you will need to detach existing wiring and combine wiring colors together (black to black, white, to white, etc) and use pigtails to wire run a single wire to the outlet. 
6. Follow the same steps as you would connecting wire to the new outlet found below to attach wiring to the existing outlet. 
7. At the new location, cut a hole in the wall where you want the outlet to be.
8. Attach an electrical box (old-work type) to the wall using screws to tension the boxes tabs and secure it in place.

Steps to follow for both new outlet installation and replacing existing outlets:  

1. Strip the outer insulation from the cable and separate the wires.
2. Strip about ½ inch of insulation from each wire (black, white, and green or bare). Depending on your house and wiring, you may have a 4th gray wire or even a red wire in place of black. The gray wire is the neutral wire that is often needed for smart devices to correctly function. If your device specifies the need for this wire, and you do not have one, please consult an electrician.  A red wire indicates the outlet is switched, and is also “hot” like a black wire. One will commonly find these routed to lights or fans. 
3. Connect the black wire to the brass-colored screw on the outlet (designated as “line”) and tighten the screw. This wire is the "hot" wire and carries the electrical current.
4. Connect the white wire to the silver-colored screw (designated as “line”) on the outlet and tighten the screw. This wire is the "neutral" wire and completes the circuit.
5. Connect the green or bare wire to the green screw on the outlet and tighten the screw. This wire is the "ground" wire and provides a path for electricity to safely flow to the ground in case of a short circuit.
6. Gently push the outlet into the box, making sure not to pinch any wires.
7. Screw the outlet into the box.
8. Install the cover plate.
9. Turn the power back on and test the outlet to make sure it's working.