Optical and digital zoom are two different things
With optical zoom, the focal length of the lens changes. The lens elements move relative to each other, resulting in a smaller field of view and your subject appearing larger on the sensor.
Suppose you are photographing with a zoom lens of 24-70mm. When you zoom from 24 to 70mm, your subject is actually projected larger on the sensor. You essentially continue to use the full sensor.
Digital zoom works differently. The camera or phone uses a smaller part of the image and then enlarges it. You can actually compare it to cropping afterward and then viewing that crop in full screen.
The difference is important. Optical zoom changes the image that the lens projects onto the sensor. Digital zoom only works with the image information that the sensor has recorded.

Digital zoom is actually mainly cropping
Suppose your camera takes a photo of 6000 by 4000 pixels. That is a total of about 24 megapixels.
When you digitally zoom in 2x, you are using only about half of the width and half of the height in a simple crop situation.
Instead of 6000 by 4000 pixels, you then have about 3000 by 2000 pixels left. That is only 6 megapixels.
This is an important detail: 2x digital zoom does not mean that you simply retain half of your resolution. Since both the width and height are halved, about a quarter of the original number of pixels remains.
Your camera or phone can then upscale that smaller image back to, for example, 24 megapixels. The file may then have the same dimensions again, but that does not mean that the original details have returned.
The missing pixels must be calculated based on the pixels that are still available. Nikon describes this process in classic digital zoom as interpolation and notes that this can reduce image quality.
Why does quality decline?
A camera sensor can only register details that actually hit the used pixels. When you digitally zoom in, you are using fewer pixels to create the same final image.
Small details thus have fewer and fewer pixels available. Think of hairs, blades of grass, feathers, letters in the distance, or structures in buildings. With significant digital zoom, these details can slowly blend together.
Additionally, noise and small errors are also magnified. A little noise that is hardly visible in the normal photo can become much more noticeable after a strong digital enlargement.
Software often tries to hide this with noise reduction and sharpening. As a result, the image can ultimately look strangely smooth or overly sharp.
The further you digitally zoom in, the more software has to reconstruct or estimate how certain details might look.
Why does digital zoom sometimes look good on a modern phone?
With smartphones, digital zoom is now less straightforward than just making a crop. Modern phones combine multiple techniques to create a zoomed-in photo as well as possible.
Many smartphones, for example, have multiple cameras with different focal lengths. You can have an ultra-wide, standard, and telephoto camera in the same device. When you press 3x, your phone can actually switch to a camera with a longer focal length.
Between those fixed focal lengths, the phone often uses a combination of optical and digital techniques.
Additionally, smartphones can take multiple photos in quick succession and combine information from those images. Software can compare details, correct motion, reduce noise, and sharpen the final image.
That is why it is sometimes referred to as hybrid or computational zoom. The result can be significantly better than simply taking one photo and cropping a small piece out of it.
However, even smart software cannot create unlimited detail. If you zoom in digitally far enough, the quality will ultimately decrease.
2x does not always mean the same on a phone
The zoom buttons on a smartphone can therefore be quite confusing.
If you have a phone with a main camera and a separate 3x telephoto camera, then 3x usually means that the phone can switch to that telephoto camera. If you choose 2x, the phone may use a crop from the main camera.
In some phones, the main sensor has so many pixels that such a crop still retains sufficient resolution. For example, Apple uses the central part of the sensor in recent 48-megapixel main cameras to create a 2x view of 12 megapixels. Apple calls this 'optical quality', although it is technically not the same as a separate 2x telephoto lens.
Conditions also play a role. The telephoto camera in a phone sometimes has a smaller sensor or a less light-sensitive lens than the main camera. In low light, the software may decide not to switch to that telephoto camera but to digitally zoom in on the image from the main camera.
You might choose 3x, but your phone ultimately decides which camera and which image information to use for that.
Is digital zoom always wrong?
No. It mainly depends on how much you zoom and what you need the photo for.
A small digital crop can result in hardly visible quality loss, especially when you start with a high resolution. For a photo that will ultimately only be viewed on a phone screen or social media, you often do not need all the original megapixels.
Digital zoom can also be handy when you want to take the photo directly with the right crop. You see immediately while photographing which part will ultimately be in the frame and do not need to crop afterward.
The problem mainly arises when you use digital zoom because you think you are capturing more detail. With regular digital zoom, that is not the case.
If you can physically get closer, that is often better. If you have optical zoom or a separate telephoto camera available, you should also use that when maximum image quality is important.
But sometimes you simply cannot get closer. Then a digital enlargement can still be more useful than having no photo at all.
Digital zoom or cropping afterward?
If digital zoom largely comes down to cropping, you might wonder why you don’t just make a crop afterward.
That has a clear advantage. When you photograph without digital zoom, you retain the full image. You can later decide how much to crop and possibly keep some extra space around your subject.
With strong digital zoom, that information outside the chosen frame can already disappear during saving, depending on the camera, phone, and file format.
On the other hand, digitally zooming while photographing can help you better assess your composition. Your subject appears larger in the frame immediately, making timing and placement easier to see.
The main lesson is therefore not that you should never use digital zoom. You should mainly know what happens.
Optical zoom ensures that your subject appears larger on the sensor. With digital zoom, a smaller part of the recorded image is usually used and enlarged.
This can work fine, especially with modern software and sensors with many pixels. But every time you zoom in digitally further, you ultimately lose image information. A zoom button can make the subject seem closer, but it cannot endlessly reveal details that the sensor never captured.