GPSBabel is a conversion tool for geographic data formats, espcially focusing on GPS, tracking, routing and way points. It can read and write a plethora of file formats.
For the full list of commands, switches and formats please refer to the man pages of gpsbabel.
Convert KML to GPX:
gpsbabel -i kml -o gpx -f <in.kml> -x transform,rte=trk -x nuketypes,waypoints,tracks -x simplify,error=0.5k -F <out.gpx>
<in.kml> with the path and name of the input file and
<out.gpx> with the path and name of the file to store the result.