18 inches is the legal minimum, but never cut it that short. 18.5 is the recommended minimum since about a half inch goes into the upper receiver, and some police might think 18 is really 17.5 which would be illegal.
Plus, any modification to a stock weapon makes it harder to explain to a DA or jury that you were only acting in self defense. The modification make it look like you had the intent to kill, the desire to harm etc.