I've been playing around with my RPi3B lately and for whatever reason wanted to reformat my SD card. I'm unsure how I did it but now when I insert the card it says there is only 31mb of space. The card is 120gb but the computer is not recognizing anything but 31mb. How can I fix this?
A hard disk can be separated into several partitions each appearing as independent drive with its own letter in Windows explorer.
This can be done with an SD-card or USB flash drive, too, but it is normally very uncommon, except when an operating system is installed on the drive. There is typically a small drive of just a few 10MB for initial booting (e.g. UEFI), and at least one larger partition for operating system and data.
Now, this smaller partition is formatted with FAT, which Windows can understand. You formatted this partition, and it is empty now.
The larger partition is formatted with ext4 in case of Raspbian. Windows doesn't understand this, and so doesn't display it, or even assign a letter for it.
Go to disk management in Windows. In the lower half of the window, each physical hard drive is shown as row, with the partitions as blocks on it. You'll notice the small 30MB partition, and a large "unknown" one. Delete both, create a new partition over the entire space, and format it. After, you have the full capacity "back".
Try formatting the SD with the sdformater:
This happened to me once, several years ago. I installed on a new 8GiB card, and it failed in a couple of days and was unformattable.
I contacted Sandisk, and was advised to return the card, to be replaced under warranty. I gather this is a known, but rare, problem.