A foreign exchange student walks into a classroom. It might sound like the beginning of a joke, but in reality, it's the way many non-Japanese characters are introduced in anime, and the parts they play in the story can be wildly different from any other character.
The role of the foreigner in anime is a tricky one. With only roughly 2.3 percent of Japanese people originating from outside the country, there's not a lot of diversity that could serve as inspiration for anime stories or characters. The number of foreign characters is actually hugely exaggerated compared to the actual statistics, which has led to some general stereotypes about people who come to Japan.
Some are devoted otaku who worship Japanese culture while getting it all wrong, some are cute blondes with big blue eyes who can't speak a word of Japanese correctly, and some are more worrisome stereotypes about people with darker skin tones. However, a few foreign characters in anime over the years have avoided these stereotypes and show that things are gradually changing for the better when it comes to potentially harmful portrayals.
Foreigners from North America or Europe are well-represented in anime; although, they are often part Japanese. Asuka Langley Soryu from Neon Genesis Evangelion is an American citizen but one-quarter Japanese and was raised in Germany. Tamaki Suoh from Ouran High School Host Club is both French and Japanese -- a fact that actually portrays him as more desirable. Tamaki doesn't exhibit any foreigner stereotypes, shown as being extremely clueless about everyday life only due to his ultra-wealthy upbringing.
Sk8 the Infinity features Langa Hasegawa, who is Canadian and Japanese. His Canadian roots are actually used to his advantage for skateboarding, as he draws from experiences in snowboarding in a country famous for its mountain locations. This use of background for an actual plot point gives meaning to Langa's Canadian upbringing instead of just adding meaningless details to make the new transfer student seem more interesting -- a clever use of an old trope.
The discussion of foreigners from non-European or North American countries gets a little more complicated due to racial issues. Many Japanese athletes with darker skin tones have spoken up recently about the harassment they face, and attempts to address racism in Japan have largely been met with dismissal -- in part because it's seen as an American problem and in part because there's so relatively little cultural diversity in Japan. The end result is characters like Sister Krone from The Promised Neverland, who seem plucked straight out of an American minstrel show.
Foreign anime characters from Asia and Africa can and do have stereotypes attached to them, but several over the years have been positive influences on the industry. Hei from Darker Than Black is of Chinese nationality, which is relevant due to the history of armed conflict between Japan and China but also for being the second most common nationality in Japan. Hei is far too busy with the plot to fall into any stereotypes, but presents himself as a timid yet helpful exchange student when needed.
Musa Kamara from Run With the Wind is a sponsored student from Tanzania. He is a gentle and supportive character who nevertheless gets annoyed when people make the assumption that Black people will be fast runners. Musa struggles at times with converging Tanzania and Japan, unsure of how much he should try to distance himself from his nationality and how much he should embrace it. This is a wonderful example of a foreign character addressing their foreigner status, as well as the subtle racism he encounters.
Sonny Boy features Rajdhani, who is implied to be of Indian descent or nationality. Rajdhani is extremely intelligent when it comes to math and science and is always open with his discoveries, treated just like any other valuable member of the student group. Another character with origins in the Indian subcontinent is Akira Agarkar Yamada from Tsuritama. Akira wears a turban as well as having darker skin, and he endures a few jokes about his turban which serve as a reminder that casual racism is there, even when coming from a likable character. However, Akira's foreigner status really does not matter to Tsuritama's story -- he's hardly the strangest transfer student. Instead, he is given a role that allows him both serious and comedic moments to become a fully realized character.
These are all examples of foreigners finding their place in Japan's society. Some confront racism while some do not. Some use the foreigner status to help with the plot while others are simply from another country for no apparent reason. However, all these examples take place in modern-day Japan.
In contrast, Yasuke is a story rich in history that was adapted into an anime series in 2021. Yasuke was a real historical figure of African origin who served Oda Nobunaga. Although he was originally a slave, he gained Nobunaga's favor and is speculated to have been given property, a katana and a place at Nobunaga's side. Studio Mappa produced the series Yasuke, which gives history a mythical twist. In the show, Yasuke is still a slave brought before Oda Nobunaga, but feudal Japan is imbued with magic and advanced technology. Even 20 years after Nobunaga's fall, Yasuke is still known as the Black Samurai and becomes embroiled in conflict once more. Just like the true Yasuke, the Yasuke in the show is subject to intense racism that doesn't shy away from Japan's use of slaves.
Representation is hard to get right when Japan's population remains so homogeneous. With comparatively few real-life examples to draw from, it's little wonder that the representation of foreigners often involves certain tropes or promotes harmful stereotypes. However, as technology makes global communication easier for all, the influence of foreign ideas and people can hopefully lead to further positive growth when it comes to the foreign exchange student who walks into a classroom.