String str ="{"employees":[{"firstName":"Bill","lastName":"Gates"},{"firstName":"George","lastName":"Bush"},{"firstName":"Thomas","lastName":"Carter"}]}"; String s = str.replaceAll("\"", "\\\\\""); System.out.println(s);