It's easiest to get your payment from the PMT function in Excel or Google Sheets. So a $100,000 30 year mortgage at 3% looks like this:
=PMT(0.03/12,360,100000)
The basic calculation is pretty simple. You take the annual interest rate, say 3%, divided by 12, times the existing principal balance:
Month Principal Interest Payment
1 100,000.00 250.00 -421.60
2 99,828.40 249.57 -421.60
3 99,656.37 249.14 -421.60
4 99,483.91 248.71 -421.60
5 99,311.02 248.28 -421.60
6 99,137.70 247.84 -421.60
7 98,963.94 247.41 -421.60
8 98,789.75 246.97 -421.60
9 98,615.13 246.54 -421.60
....and then .........
111 78,304.34 195.76 -421.60
112 78,078.50 195.20 -421.60
113 77,852.10 194.63 -421.60
114 77,625.13 194.06 -421.60
115 77,397.59 193.49 -421.60
116 77,169.49 192.92 -421.60
...... but then ......
339 9,016.01 22.54 -421.60
340 8,616.95 21.54 -421.60
341 8,216.90 20.54 -421.60
342 7,815.84 19.54 -421.60
343 7,413.78 18.53 -421.60
344 7,010.71 17.53 -421.60
345 6,606.64 16.52 -421.60
etc.
The idea is that borrowers would like to have a predictable payment. The earlier payments are proportionally more interest than principal than later payments are but that's because there is much more principal outstanding on month 1 than on month 200.