I'll assume your passport requires a visa to visit Thailand.
Per TIMATIC, the database used by airlines:
TWOV (Transit Without Visa): Passengers transiting through Bangkok (BKK) with a confirmed onward ticket for a flight to a third country within 12 hours. They must stay in the international transit area of the airport and have documents required for the next destination.
This TWOV facility does not apply to passengers traveling
on Angkor Air (K6), Beijing Capital Airlines (JD), Business
Air (8B), Cebu Pacific (5J), Eaststar Jet (ZE), Golden
Myanmar Airlines (Y5), Indigo (6E), Jeju Air (7C), Jet Asia
Airways (JF), Jetstar (JQ), Jetstar Pacific (BL), Jin Air
(LJ), JuneYao Airlines (HO), Lao Central Airlines (LF),
Mandara Airlines (RI), Norwegian Air (DY), Okay Airways
BK), Orient Thai Airlines (OX), Regent Air (RX), Shandong
Airlines (SC), Shanghai Airlines (FM), Shenzhen Airlines
(ZH), Siberia Airlines (S7), Sichuan Airlines (3U), South
East Asian Airlines (DG), Spice Jet (SG), Thai Smile
Airlines (WE), Tianjin Airlines (GS), Tiger Air (TR), Trans
Aero (UN), Turkmenistan Airlines (T5), T'way Airlines (TW),
Ural Airlines (U6) and VietJet Air (VJ).
However, for entering Thailand:
Visa required, except for Nationals of India with a normal
passport traveling as tourists can obtain a visa on arrival at
Bangkok (BKK and DMK) [...] for
a maximum stay of 15 days. They must have a confirmed return/onward ticket with a departure within 15 days from arrival date, 1 recent passport photo and at least THB 10,000.- per person (or THB 20,000.- per family). Their passport must contain at least 1 unused visa page.
This means you don't need a visa in advance; should you need to clear immigration at any point (which TIMATIC suggests you have to do), get a visa at the airport before doing so.