In an interview with the New York Times, Spider-Man: Far From Home writers Chris McKenna and Erik Sommers revealed that while it was always part of the plan to reveal Spider-Man’s identity, the manner in which it happens was initially very different. McKenna said:

Sommers added that the duo initially debated on how far to push the angle and finally decided that it’s best to put Spidey in a very, very difficult situation before the sequel. Spider-Man: Far From Home is currently screening in Malaysian cinemas. 

Spider Man  Far From Home Initially Had a Completely Different Ending - 5