Japan is to ask thousands of foreigners about their encounters with racism as the country adapts to a record number of non-Japanese residents and tourists.

In an unprecedented survey, the justice ministry will ask 18,500 foreign residents aged over 17 to describe their experiences of being discriminated against in the workplace or in their free time, and how they would like the government to respond, the Asahi Shimbun newspaper reported. They will also be asked if they have witnessed racist incidents.

The number of foreign residents in Japan stands at about 2.3 million – or 2% of the population – and a record 20 million foreign tourists have visited the country so far this year.

International pressure on Japan to take racism more seriously has grown amid a rise in reports of hate speech in the past three years, mostly targeting members of its large ethnic Korean population.

Many of the 400,000 Korean residents who have not taken Japanese citizenship are the descendants of people who were brought over as forced labourers during Japan’s 1910-45 colonial rule of the Korean peninsula.

Tokyo, Osaka and other cities have experienced a rise in anti-Korean demonstrations by rightwing extremist groups, such as Zaitokukai, whose supporters have described ethnic Koreans as “criminals” and “cockroaches” and called for them to be killed.

In response to Zaitokukai’s activities, the national police agency in 2014 deemed the group a potential threat to law and order due to its “extreme nationalist and xenophobic” ideology.

Makoto Sakurai, the former head of Zaitokukai, won 110,000 votes in this summer’s election for Tokyo governor on a platform that included calls for the abolition of public assistance for non-Japanese people.

In a rare court ruling against racial discrimination, the group was ordered in 2013 to stop a hate speech campaign against a school for children whose families have ties to North Korea and pay 12m yen (£94,000) in damages.

Japan’s parliament passed a law against hate speech in June. The law, which has been criticised for not carrying penalties for offenders, encourages local governments to take measures to eradicate hate speech.

Osaka, which is home to a large ethnic Korean community, became the first city to enact a hate speech ordinance the following month.

Racist incidents of a different nature collated by the justice ministry last year involved non-Japanese people who were refused bookings at hotels or denied contracts for apartments, and children who were bullied at school.

The ministry’s survey will be conducted in 13 languages, including English, Chinese and Korean, and the results will be released by the end of March.