Converting string "true" / "false" to boolean value You could simply have: var result = (str == "true"). var val = (string === "true");