how to trim a string in javascipt code example Example 1: javascript trim spaces value = value.trim(); Example 2: javascript whitespace strip yourvariable.trim()