It's really going to depend on which country your passport is from. Japan has a number of different arrangements with different countries that could either mean no visa required at all, or you get a tourist visa as you come in or you need to apply for a tourist visa in your country before you leave. Always best to check before you go.
We live in Australia and fortunately, as an Australian tourist we get a 3 month tourist visa as we arrive, it's always a fast, hassle free process.
Hot tip - make sure you have the address of where you are going to be staying handy when you are passing through immigration into Japan. You'll need it on the immigration paperwork, it just makes things a bit quicker. They may also ask you directly when you are in the exit queue. I'd recommend that you keep a small post it note in your passport with the address of where you are planning to stay including the phone number. If it's a hotel the details are easy, if you are using AirBnB make sure you have the address, you can have your host give it to you in Japanese and English to make things really clear.
So bear in mind this info above relates to tourists and some business travellers. I'd always recommend taking a look at the Japanese consulate website in your country to find out exactly what requirements you need to meet before you travel.
If you're looking at other types of visas (student, business and working) you'll definitely need to apply before you come to Japan and make sure to explore all of the conditions that must be met. There are no shortcuts here, you need to apply for the correct visa and you need to make sure you meet the specific criteria. The Japanese bureaucracy is in full effect when dealing with Government forms, there is no wiggle room. Have everything organised before you depart, if you think you'll be able to do it on arrival you are completely wrong and may be turned back.
The great news though for regular travellers is that getting through Japanese Immigration is fast, efficient and really straightforward, we are generally through in under 30 minutes from getting off the plane, it's wonderful and certainly not like travelling to any other country we've been to.
Another Hot tip - If you're hungry when you arrive, your'e in for a surprise. Don't go rushing about like a crazy person, there are lots of great food choices at the airport and here's the most amazing thing, unlike airport food in most western locations (I'm talking about you Australia) they are sooo inexpensive, fast, clean and delicious. Whenever we arrive (it's usually around 8pm) we grab something amazing as soon as we get our bags, then either head into Tokyo or to a local hotel near the airport.
If you catch one of the high speed trains into Tokyo from Narita there are only snack services on the train so getting something delicious and inexpensive just after we have arrived in Japan really works for us. The only catch is that the office that exchanges JR Rail Pass Vouchers for JR Rail Passes does close fairly early (think it is around 8 or 8:30) this isn't an issue if you don't need to use the JR pass that night so save the hassle (there is usually a plane full of people trying to jam into the smallish office to redeem passes) and do it at a JR office the following day or just before you plan to use it.
Sorry that doesn't help anyone needing to convert their pass that night, my personal advice is (if arriving at night) add a day to your trip when you start planning and stay at a hotel in Narita then start your holiday or travel the next day. Hotels in Narita are great value, large, compfortable and only 5 to 10 minutes from the airport via the complimentary bus service. You can catch the same bus back to the airport the following morning, convert your pass and head wherever you are planning without the stress.
I think that getting through Japanese customs and immigration is possibly the fastest of any country I have visited. Have your documents ready to go and get into the first of what will be may lines, although in Japan the lines usually move fast and are extremely orderly.
One More tip - If you are using prescription medication, make sure you take the prescription with you, some prescription medications are not legal in Japan. Always best to check and if you have your prescriptions with you then you will be more likely not have any issues. I think also best to make sure to bring along a little bit more than you are going to need for the time you are in Japan. I certainly wouldn't be planning on buying my prescriptions whilst there as my understanding is that many Japanese pharmaceuticals are not as strong as western meds, so it may muck up your dosages. As always check with your GP.
Once you've had your passport stamped you are good to go, collect your bags and go through the final check and head to your hotel, next city, train, plain bus or whatever.