//Here is a string containing white space let strWithSpace = "This is swift coding" let strWithNoSpace = strWithSpace .replacingOccurrences(of: " " , with: "%20" ) print ( strWithNoSpace ) OutPut:- This%20is%20swift%20coding Happy Coding:)