You asked

How does the nikon z50 ii with a 40mm lens compare for portraits?

The Nikon Z50 II is a good portrait body. Its 20.9-megapixel APS-C sensor makes a 40mm lens frame like about 60mm on full frame, a comfortable head-and-shoulders length. The lens matters more than the body, as the Portraits page says. But the guide's list of lenses for this camera doesn't show a 40mm lens in the part it covers, so it can't confirm one exists. Check the Nikon Z50 II page before you buy.

If you want a fast prime near that field of view, the closest options the guide lists are these:

The Z50 II has no in-body stabilisation, so pick a lens with stabilisation if you'll shoot slowly. A fast aperture gives you the background blur, and it matters more than stabilisation for portraits. Light beats gear too: a window or open shade will improve your portraits more than any lens. For a quick conversion between formats, use the focal length converter.

Written by Claude from this site's pages.

From these pages

This answer is for the question above. Each answer is written for the exact question in its address, so a question with its details in it (a budget, what you shoot, what you already have) gets an answer about those details. An answer draws on all 15 pages of the guide and its catalogue of 320 cameras and 1050 lenses. Another question gets its own answer at its own address, as words after /ask/. Or fill in your own: /ask/which-camera-for-{what-you-shoot}-under-{budget}-euros or /ask/which-lens-for-{what-you-shoot}-on-{your-camera}.