trim whitespace on string js code example Example 1: javascript trim spaces value = value.trim(); Example 2: javascript whitespace strip yourvariable.trim()