Visitors to the U.S. could be forced to provide cellphone contacts and social-media passwords and answer questions about their ideology, according to Trump administration officials, measures that could intrude into the lives of millions of foreigners.

The changes being considered could apply to visitors from America’s closest allies as well as other nations and include subjecting more visa applicants to intense security reviews. Together, they would amount to the “extreme vetting” President Donald Trump promised as a candidate...